Skip to content

Instantly share code, notes, and snippets.

@erdii
Last active November 15, 2016 14:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdii/2f56556b59447db83bc9 to your computer and use it in GitHub Desktop.
Save erdii/2f56556b59447db83bc9 to your computer and use it in GitHub Desktop.
Dockerizing Postgres

Dockerizing Postgres

docker run --name postgres -e POSTGRES_PASSWORD=YOURSECRETPASS -d -v /your/db/path:/var/lib/postgresql/data postgres

then link other containers with this one

using systemd:

[Unit]
Description=Postgres container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a postgres
ExecStop=/usr/bin/docker stop -t 2 postgres

[Install]
WantedBy=local.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment