Sign inSign up

sawet/pgadmin4

By sawet

Updated over 7 years ago

Image
0

259

sawet/pgadmin4 repository overview

PGAdmin4 with Postgres server on Docker

  1. Create file pg.yml and copy the code below to the file.
  2. Run: docker-compose -f pg.yml --verbose up
  3. Postgres Username: user Password: test123
  4. PGAdmin4 Email: [email protected] Password: admin
version: '3.5'

services:
  postgres:
    container_name: postgres_container
    image: postgres
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-user}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-test123}
      PGDATA: /data/postgres
    volumes:
       - postgres:/data/postgres
    ports:
      - "5432:5432"
    networks:
      - postgres
    restart: unless-stopped
  # When adding server above, use postgres as host/address.
  pgadmin:
    container_name: pgadmin_container
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
    volumes:
       - pgadmin:/root/.pgadmin
    ports:
      - "${PGADMIN_PORT:-5050}:80"
    networks:
      - postgres
    restart: unless-stopped

networks:
  postgres:
    driver: bridge

volumes:
    postgres:
    pgadmin:

To import .dump file (backup DB file) to database

Original Link

  1. Find the name and id of the Docker container hosting the Postgres instance
  • Run: docker ps -- check container
  1. Find the volumes available in the Docker container
  • Run: docker inspect -f '{{ json .Mounts }}' <container_id> | python -m json.tool
  • Example: docker inspect -f '{{ json .Mounts }}' 6ba74ec3411b | python -m json.tool
  1. Copy dump into one of the volumes
  • Run: docker cp my_data.dump my_postgres_1:/backups
  • Example docker cp latest.dump 6ba74ec3411b:/data/postgres
  1. Get the database owner to run pg_restore command
  • Run: docker exec <container_name> pg_restore -U <database_owner> -d <database_name> <path_to_dump>
  • Example: docker exec 6ba74ec3411b pg_restore -U user -d localhost /data/postgres/latest.dump

Tag summary

Content type

Image

Digest

Size

96.9 MB

Last updated

over 7 years ago

docker pull sawet/pgadmin4