Created
June 17, 2020 20:11
-
-
Save rponte/c3637d488b38ce0c39df76d2c6b34f79 to your computer and use it in GitHub Desktop.
Docker-compose: PostgreSQL and PgAdmin
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
| # Use postgres/example user/password credentials | |
| version: '3.1' | |
| services: | |
| db: | |
| image: "postgres:10.6" | |
| restart: always | |
| ports: | |
| - 5432:5432 | |
| environment: | |
| POSTGRES_USER: ${POSTGRES_USER:-postgres} | |
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme} | |
| volumes: | |
| - database-data:/var/lib/postgresql/data/ # persist data even if container shuts down | |
| - ./bootstrap:/docker-entrypoint-initdb.d | |
| pgadmin: | |
| image: adminer | |
| restart: always | |
| ports: | |
| - 8080:8080 | |
| volumes: | |
| database-data: # named volumes can be managed easier using docker-compose |
Author
Author
Running pg_activity to monitoring Postgres instance:
Just run the commands below to install in the container where the postgres is running:
docker-compose exec <pg_server_name> bash # or docker exec -i -t postgres bash
apt update && apt install pg-activity && pg_activity -U postgresFor more details, see this Reddit comment.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Running PostgreSQL 13.x container via command line:
We can start and stop the container as well: