Last active
October 29, 2018 15:06
-
-
Save fdocr/15cabd924c44f941b8160ce3509687ae to your computer and use it in GitHub Desktop.
Create postgres Docker container & simple management commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################### | |
| # 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