Skip to content

Instantly share code, notes, and snippets.

@tingwei628
Created October 27, 2019 15:20
Show Gist options
  • Save tingwei628/8584ddefc5d8e85f73566d5ab96bdc84 to your computer and use it in GitHub Desktop.
Save tingwei628/8584ddefc5d8e85f73566d5ab96bdc84 to your computer and use it in GitHub Desktop.
use postgresql and pgAdmin in docker
version: "3.4"
services:
pgAdmin:
restart: always
image: dpage/pgadmin4
ports:
- "8000:80"
environment:
PGADMIN_DEFAULT_EMAIL: 1234@admin.com
PGADMIN_DEFAULT_PASSWORD: 1234
volumes:
- pgadmin:/var/lib/pgadmin
postgres:
restart: always
image: postgres
container_name: "postgres_container"
ports:
- "5432:5432"
environment:
POSTGRES_USER: me
POSTGRES_PASSWORD: 1234
POSTGRES_DB: testDb
volumes:
- pgvol:/var/lib/postgresql/data
volumes:
pgvol:
pgadmin:
@tingwei628
Copy link
Author

tingwei628 commented Oct 27, 2019

step1. pull docker image postgresql and pgAdmin

step2. docker-compose up -d (creare services in detached mode)

step3. open pgAdmin with 0.0.0.0:8000 in the browser


pgAdmin

email: 1234@admin.com
password: 1234

Connect to postgres

  • host is to enter by docker network inspect pgv_default to check postgres_container Ipv4
  • user: me
  • password: 1234
  • db: testDb

Note

If stop these services, use docker-compose stop

if start these services, use docker-compose start

if delete these services, use docker-compose down

if delete all docker volumes, use docker volume prune

@silvesterkkk
Copy link

hi, not sure if this is forum for a question, if not please let me know.
I am new to docker, and wonder if those host volumes (i.e. pgvol & pgadmin) are relative paths?

@tingwei628
Copy link
Author

tingwei628 commented Aug 14, 2020

@silvesterkkk
Copy link

Thank you, appreciate getting back to me.

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