Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 2.11 KB

README.md

File metadata and controls

26 lines (22 loc) · 2.11 KB

postgres-docker

Postgres DB and pgadmin with Docker Compose.

Setup docker and environment variables

  1. Obtain the following images:
    • docker pull postgres:14.5 following instructions here.
    • docker pull dpage/pgadmin4:latest
  2. Edit compose.yaml file as described here.
  3. Edit the .env file for updating variables. Locate this in the same directory as the compose yaml configuration.

Create local directories and set permissions

  1. Make directories ./pgdata and ./pgadmin.
  2. Change permissions on pgadmin via: chown -R 5050:5050 pgadmin as discussed here.
  3. From the directory containing the .env and the compose.yaml files type: docker compose up

Connect pgadmin to postgres

  1. Navigate to localhost:5050 and log in using the criteria set in the .env file.
  2. Under "Quick Links" click on "Add Server" and a "Register - Server" window appears.
  3. In the "General" tab, define a "Name" for the server, e.g. "test-server", could be anything.
  4. In the "Connections" tab, set host name/address to be "postgres" (Docker will resolve this to be the container name specified in compose.yaml).
  5. Populate other fields as described here.

Using host machine data in pgadmin

  1. The host directory ./pgadmin is linked to the pgadmin container directory /var/lib/pgadmin. This host directory needs to be empty when the containers are first started, as pgadmin will populate user session storage in this directory.
  2. Once the containers are up, pgadmin will have created the directory /var/lib/pgadmin/storage/admin_admin.com (in the pgadmin container) for the user with email [email protected].
  3. Scripts and data may be placed in the host directory ./pgadmin/storage/admin_admin.com for use in the pgadmin container.