Make sure you have already installed Docker.
By running below command, you can see docker images you have on your local computer.
You’re going to need postgres and dpage/pgadmin4 images for PostgreSQL local set up but before pulling these images if you ever want to remove an image, run below command.
Then pull the required images.
To see if you successfully pulled these images, you can run
By running below command, you can see docker containers you have on your computer.
Before creating containers from postgres and dpage/pgadmin4 images, if you ever want to remove a container, run below command.
Run below command to create postgres container.
— name : postgres container name on your local
POSTGRES_USER : postgresql db user name
POSTGRES_PASSWORD : postgresql db password
POSTGRES_DB : postgresql db name
Run below command to create dpage/pgadmin4 container.
PGADMIN_DEFAULT_EMAIL : pgAdmin page login email
PGADMIN_DEFAULT_PASSWORD : pgAdmin page login password
— name : dpage/pgadmin4 container name on your local
To see if these containers running successfully, you can run
Last but not least, we need to look at IP address of the PostgreSQL container. We will use that IP address while defining connection in pgAdmin. Run below command and copy the IP address parameter.
( something like “IPAddress”:”172.17.0.2" )
Then connect to below address to login pgAdmin.
Add new server with these parameters.
Host name/address : IP address that you copied above
Port = 5432
Maintenance database : POSTGRES_DB name, we assigned it above as dockerdb
Username : POSTGRES_USER username, we assigned it above as dockeruser
Password : POSTGRES_PASSWORD password, we assigned it above as dockerpass
Now, you can start to use PostgreSQL database on Docker.