Skip to content

Instantly share code, notes, and snippets.

Created Mar 20, 2020
What would you like to do?
running postgresql on your laptop without installing it (using docker) . with connections to python

docker network create pg

docker run -it --rm -P -p 5432:5432 --name pg -e POSTGRES_PASSWORD=password -e POSTGRES_USER=postgres -e POSTGRES_DB=production -v pgdata:/var/lib/postgresql/data --network=pg postgres

pgdata is the name of the docker volume. You can check it using docker volume ls and docker volume inspect pgdata. You can delete the docker volume by docker volume rm pgdata and prune all volumes using docker volume prune docker volumes are created in your central docker directory (usually /var/lib/docker/overlay2 ). You generally dont need to care about this.

You can now access it in many ways:

psql postgresql://postgres:password@localhost:5432/production

docker run -it --rm --network pg postgres psql -h pg -U postgres

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