Skip to content

Instantly share code, notes, and snippets.

@sgyyz
Last active July 4, 2022 04:13
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save sgyyz/1012e697542ccd3d5e3fe71bc7f98521 to your computer and use it in GitHub Desktop.
Save sgyyz/1012e697542ccd3d5e3fe71bc7f98521 to your computer and use it in GitHub Desktop.
Postgres & PgAdmin docker-compose.yml
version: '3'
services:
postgres:
image: postgres
ports:
- "5432:5432"
volumes:
- pg-dataset:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD:
pgadmin:
image: dpage/pgadmin4
depends_on:
- postgres
ports:
- "53603:53603"
- "80:80"
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: root
volumes:
pg-dataset:
@sgyyz
Copy link
Author

sgyyz commented Jan 20, 2020

How to run it?
Copy these content into your docker-compose.yml file and then run the docker through docker-compose up or docker-compose up -d.

Configuration
It's better to update configuration based on your own environment. And follow the guide for postgres and dpage/pgadmin4.

Use it

  1. after you run the command success, then you can open your browser and access http://localhost
  2. login with the email and password you defined indpage/pgadmin4 in docker-compose.yml
  3. connect the Postgres server with the host : postgres, username: postgres, password: empty

@davidshare
Copy link

Thank you for this. I am using a similar setup, but I am not able to login to pgadmin. Seems it uses a default user and password I am not aware of, and ignores the one I specified in the environments.

I created a StackOverflow question here, in case you want to look at the details.

https://stackoverflow.com/questions/68588110/pgadmin4-does-not-change-default-email-and-password-in-docker-compose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment