Postgres DB and pgadmin with Docker Compose.
- Obtain the following images:
docker pull postgres:14.5
following instructions here.docker pull dpage/pgadmin4:latest
- Edit compose.yaml file as described here.
- Edit the .env file for updating variables. Locate this in the same directory as the compose yaml configuration.
- Make directories
./pgdata
and./pgadmin
. - Change permissions on
pgadmin
via:chown -R 5050:5050 pgadmin
as discussed here. - From the directory containing the
.env
and thecompose.yaml
files type:docker compose up
- Navigate to localhost:5050 and log in using the criteria set in the
.env
file. - Under "Quick Links" click on "Add Server" and a "Register - Server" window appears.
- In the "General" tab, define a "Name" for the server, e.g. "test-server", could be anything.
- In the "Connections" tab, set host name/address to be "postgres" (Docker will resolve this to be the container name specified in
compose.yaml
). - Populate other fields as described here.
- 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. - 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]
. - Scripts and data may be placed in the host directory
./pgadmin/storage/admin_admin.com
for use in the pgadmin container.