Repository available at: Install Postgres SQL object-relational database system on Docker
This guide aims to deploy a Postgres Database running on Docker with his Admin panel (pgadmin).
For this guide we use a Linux Ubuntu 20.xx and Postgres latest version.
Connect to your server and clone the repo
git clone https://gitlab.com/ArnaudSene/postgres-docker.git
cd postgres-docker
Edit the .env
file with required values.
cp env-custom .env
vi .env
POSTGRES_USER=postgres
POSTGRES_PASSWORD="pg password"
POSTGRES_DB="database name"
PGADMIN_DEFAULT_EMAIL="a valid email"
PGADMIN_DEFAULT_PASSWORD="pgadmin password"
PGADMIN_ENABLE_TLS: 1
PGADMIN_LISTEN_PORT: 443
Create certificate
mkdir certs
cd certs
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out pgadmin_server.crt -keyout pgadmin_server.key
Create and start containers
bash start-postgres.sh
Docker
and docker compose
must be installed on the server in order to install and start Postgres system.
Edit the .env
file with required values.
vi .env
POSTGRES_USER=postgres
POSTGRES_PASSWORD="pg password"
POSTGRES_DB="database name"
PGADMIN_DEFAULT_EMAIL="a valid email"
PGADMIN_DEFAULT_PASSWORD="pgadmin password"
The certificate will be used for Postgres admin panel pgadmin
Connect to your linux server and create a crt and key file.
where server can be for example
- username: vagrant (replace with your username)
- server : 192.168.56.38 (replace with your server IP address)
ssh vagrant@192.168.56.38
cd certs
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out pgadmin_server.crt -keyout pgadmin_server.key
The script will configure the environment, create and start containers.
bash start-postgres.sh
On the server run the following command
docker inspect postgres-docker-pgadmin-1|grep IPAddress|cut -d":" -f2|tail -1
Through a web browser enter the url to pgadmin with the IP address retrieve before.
e.g: with IP address = 10.0.0.1
Use the credentials defined in the .env
PGADMIN_DEFAULT_EMAIL="a valid email"
PGADMIN_DEFAULT_PASSWORD="pgadmin password"
server name: e.g: server_poc
hostname: postgres_container
username: postgres
password: in file
.env
POSTGRES_PASSWORD