Created
February 13, 2020 19:04
-
-
Save mattsizzle/87414e6497b7b306d43ef0e188def3a7 to your computer and use it in GitHub Desktop.
Quick and Easy PostGres SQL DB in Docker environment with optional DB restore file.
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
Quick and Easy PostGres SQL DB in Docker environment for learning or experimenting. | |
Grab Docker Image | |
# docker pull postgres | |
Create Docker container with PHP database management UI Adminer via Docker Compose | |
Create `compose.yml` | |
version: '3.1' | |
services: | |
db: | |
image: postgres | |
restart: always | |
volumes: | |
- /tmp/restores/:/var/lib/restores # Optional | |
environment: | |
POSTGRES_PASSWORD: example | |
adminer: | |
image: adminer | |
restart: always | |
ports: | |
- 8080:8080 | |
Create and start Docker containers | |
# docker-compose -f compose.yml up | |
*Optional* Restore existing DB to the container | |
# docker exec <CONTAINER> pg_restore -U postgres -d postgres /var/lib/restores/EXISTING_DB_TO_RESTORE.tar | |
*Optional* Access the container's psql CLI | |
# docker exec -it <CONTAINER> psql -h <CONTAINER> -U postgres | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment