Reference: marvinjungre. (30 Jun 2023). Setting up PostgreSQL and pgAdmin 4 with Docker. Medium.
- Podman Desktop
- pgAdmin4
-
Open the Podman Desktop application.
-
Download the latest postgres image:
podman pull postgres- Create and run the postgres container:
podman run --name postgres-db -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres- Download the latest pgAdmin 4 image:
podman pull dpage/pgadmin4- Create and run the pgAdmin 4 container:
podman run --name pgadmin-container -p 5050:80 -e PGADMIN_DEFAULT_EMAIL=user@domain.com -e PGADMIN_DEFAULT_PASSWORD=password -d dpage/pgadmin4-
Open pgAdmin via http://localhost:5050/ and login using the previously defined credentials.
-
Use the following command to obtain the postgres container's IP address:
podman inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres-db- From pgAdmin, register the new postgres server:
Name: postgres-db
Host name/address: <IP addressed obtained from step 7>
Port: 5432
Maintenance database: postgres
Username: postgres
Password: password
- From pgAdmin, navigate to the
postgres-dbserver. Right-click, Create > Database...
Database: catbase
- catbase > Schemas > Tables > Create > Table...
Name: cattable
Name: id
Data type: serial
Not NULL?: true
Primary key?: true
Name: catname
Data type: text
Not NULL?: true
Primary key?: false
-
cattable > View/Edit Data > All Rows
-
From the Data Output tab, click the Add row icon button. Then double-click the cell under the catname column to edit it. Set the value to "Bam Bam" without quotes. Lastly, click the Save Data Changes icon button.
-
Connect to the postgres server via the command line:
podman exec -it postgres-db psql -U postgres- Connect to the "catbase" database:
\c catbase- Output all of the rows from the cattable:
SELECT * FROM CATTABLE;