Docker Compose: Set up pgAdmin and Postgres in 1 minute
2 min readSep 2, 2023
Create the file docker-compose.yml
version: '3.8'
services:
pg:
container_name: pg_container
image: postgres
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: test_db
ports:
- "5432:5432"
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5555:80"
Then run the docker compose up
docker compose up -d
Now you see it is all running with
docker ps
Common Problem: Clear up when config change
When you change something like user
,password
or other configuration. Docker will try to load existing container and it might have some error like below.
Error response from daemon: Conflict. The container name "Name ..."
is already in use by container "Hash ..."
You have to remove (or rename) that container to be able to reuse that name.
Then you will clear up with
docker container prune
Common Problem: WSL issue to access localhost
localhost
is not working you need to specify the name of the docker process pg_db
where they have the DNS for them.