Skip to content

Instantly share code, notes, and snippets.

@santosh
Last active May 20, 2020 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santosh/80d16cb4601ec4fcc044e72a691fd43d to your computer and use it in GitHub Desktop.
Save santosh/80d16cb4601ec4fcc044e72a691fd43d to your computer and use it in GitHub Desktop.
Basic docker postgres setup for dev.
docker run -d --name postgres -e POSTGRES_PASSWORD=Pass2020! -v postgres-data:/var/lib/postgresql/data -p 5432:5432 postgres:11-alpine

More env vars at https://hub.docker.com/_/postgres.

Hop into the container:

docker exec -it postgres bash

And use the psql repl.

psql -h localhost -U postgres

Note that postgres is the default user. Which can be overridden by POSTGRES_USER env var.

A default database is created on the name of same user which was given, else postgres is used.

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