Install Postgres & Pgadmin4 with Nginx in docker
For personal learning purposes, running the PostgreSQL and the PgAdmin4 in docker is an easy and good way. And for some reason, we may want to use Nginx to proxy the PostgreSQL and the Pgadmin4.
Here is my configuration.
- Run the PostgreSQL in the docker
Bash
2. Run the PgAdmin4 in the Docker docker run --name postgres \
-e POSTGRES_USER=sa \
-e POSTGRES_PASSWORD=sa \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-e POSTGRES_HOST_AUTH_METHOD=scram-sha-256 \
-v /root/documents/postgresql/data:/var/lib/postgresql/data \
-p 5432:5432 \
--user "$(id -u):$(id -g)" \ # optional, depends on environment
-d postgres
Bash
3. Configure the Nginx docker run -p 8090:8090 --name pgadmin4 \
-e 'PGADMIN_LISTEN_PORT=8090' \
-e 'PGADMIN_DEFAULT_EMAIL=<Email>' \
-e 'PGADMIN_DEFAULT_PASSWORD=<Password>!' \
-e 'PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=True' \
-e 'PGADMIN_CONFIG_LOGIN_BANNER="Authorised users only!"' \
-e 'PGADMIN_CONFIG_CONSOLE_LOG_LEVEL=10' \
-d dpage/pgadmin4
-
Configure the Pgadmin4
-
Configure the PostgreSQL