Skip to content

Instantly share code, notes, and snippets.

@fdocr
Last active October 29, 2018 15:06
Show Gist options
  • Select an option

  • Save fdocr/15cabd924c44f941b8160ce3509687ae to your computer and use it in GitHub Desktop.

Select an option

Save fdocr/15cabd924c44f941b8160ce3509687ae to your computer and use it in GitHub Desktop.
Create postgres Docker container & simple management commands
###################
# Docker COMMANDS #
###################
# Create volume for persistance
docker volume create pgdata
# Create the container
docker run --name pg -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -d -v pgdata:/var/lib/postgresql/data -p 5432:5432 postgres
# Access using psql
docker exec -it pg psql -U postgres
#####################
# POSTGRES COMMANDS #
#####################
# List databases
\l
# Connect to database
\c db_name
# Describe all relations (tables) in the DB
\dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment