In my case, the IP address of my Docker host 192.168.20.160. Now, to start the db and pgadmin services, run the following command: So, you can access the PostgreSQL server using pgsql-server as the hostname (no IP address required). In the pgadmin service, a hostname alias pgsql-server to the db container is created. In the pgadmin service, the container port 80 (right) is mapped to the Docker host port 8080 (left). In the db service, the container port 5432 (right) is mapped to the Docker host port 5432 (left). In the pgadmin service, all the contents of the /var/lib/pgadmin directory will be saved permanently in the pgadmin-data volume. In db service, all the contents of the /var/lib/postgresql/data directory will be saved permanently in the db-data volume. The PGADMIN_LISTEN_PORT is used to set the pgAdmin port 80 in the container.
#Ubuntu pgadmin 4 password
In pgadmin service, the PGADMIN_DEFAULT_EMAIL, PGADMIN_DEFAULT_PASSWORD environment variables are used to set the login email and password of pgAdmin web interface respectively. The PGDATA environment variable is used to configure the PostgreSQL server to store the data to /var/lib/postgresql/data directory of the container. In db service, the POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD environment variables are used to set the default database name, admin username and admin user password for the PostgreSQL server respectively. Pgadmin service will run the dpage/pgadmin4:4.18 image (from DockerHub) in another Docker container. Here, I have created 2 services db and pgadmin.ĭb service will run the postgres:12.2 image (from DockerHub) in a Docker container. The docker-compose.yaml file should look as follows.