Postgres DB and pgadmin with Docker Compose.
- Obtain the following images:
docker pull postgres:14.5following 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
./pgdataand./pgadmin. - Change permissions on
pgadminvia:chown -R 5050:5050 pgadminas discussed here. - From the directory containing the
.envand thecompose.yamlfiles type:docker compose up
- Navigate to localhost:5050 and log in using the criteria set in the
.envfile. - 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
./pgadminis 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.comfor use in the pgadmin container.