Skip to content

john-ngai/postgres-pgadmin4-docker-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Tutorial: PostgreSQL, pgAdmin4, and Docker

Reference: marvinjungre. (30 Jun 2023). Setting up PostgreSQL and pgAdmin 4 with Docker. Medium.

Environment Requirements

  • Podman Desktop
  • pgAdmin4

Steps

  1. Open the Podman Desktop application.

  2. Download the latest postgres image:

podman pull postgres
  1. Create and run the postgres container:
podman run --name postgres-db -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
  1. Download the latest pgAdmin 4 image:
podman pull dpage/pgadmin4
  1. 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
  1. Open pgAdmin via http://localhost:5050/ and login using the previously defined credentials.

  2. Use the following command to obtain the postgres container's IP address:

podman inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres-db
  1. 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

Optional Steps for Testing the Connection

  1. From pgAdmin, navigate to the postgres-db server. Right-click, Create > Database...
Database: catbase
  1. catbase > Schemas > Tables > Create > Table...

General Tab

Name: cattable

Columns Tab

Name: id
Data type: serial
Not NULL?: true
Primary key?: true
Name: catname
Data type: text
Not NULL?: true
Primary key?: false
  1. cattable > View/Edit Data > All Rows

  2. 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.

  3. Connect to the postgres server via the command line:

podman exec -it postgres-db psql -U postgres
  1. Connect to the "catbase" database:
\c catbase
  1. Output all of the rows from the cattable:
SELECT * FROM CATTABLE;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published