Skip to content

Instantly share code, notes, and snippets.

@Rishabh04-02
Forked from ChakshuGautam/psql-setup-docker.sh
Last active October 17, 2019 09:34
Show Gist options
  • Select an option

  • Save Rishabh04-02/0ff86795e8a2219b5dd9d311f053ab2e to your computer and use it in GitHub Desktop.

Select an option

Save Rishabh04-02/0ff86795e8a2219b5dd9d311f053ab2e to your computer and use it in GitHub Desktop.
PSQL Docker setup - Cheatbook

Setup docker engine

-p 127.0.0.1:5432:5432 instead of -p 5432:5432. If you don’t explicitly tell it to run on localhost, it’ll run on0.0.0.0 which means other folks on the same network will be able to reach it. https://hub.docker.com/_/postgres => Gives a lot of info regarding docker secrets which should be the way forward.

docker pull postgres

mkdir -p $HOME/docker/volumes/postgres

docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 127.0.0.1:5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres

OR

docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 0.0.0.0:5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres:9.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment