1.2.3 - Connecting pgAdmin and Postgres
Last updated Jan 19, 2025
⛔ I recommend not pausing your workflow once you docker run -it
in this video
Youtube Video | ~10 min
✍️ In this video we will talk about using pgAdmin to manage our Postgres in Docker. We will learn about creating a network to connect our containers. Then, we get to take a look at the front end of our work and we will create a new server on pgAdmin to host our taxi dataset.
👀 Note that in 1.2.5 we will be using docker-compose in a yaml file method instead
pgAdmin
"pgAdmin is an open-source, web-based graphical user interface (GUI) tool primarily used to manage and administer PostgreSQL databases, allowing users to perform tasks like creating databases, tables, users, and executing SQL queries through a visual interface rather than just command-line commands; essentially, it's the primary management tool for PostgreSQL databases." - AI
Running pgAdmin & Postgres together
◼️ To connect the two, we need to create a network
"Container networking refers to the ability for containers to connect to and communicate with each other, or to non-Docker workloads."
docker network create pg-network
Then we want to add the network and network name to our docker run command for both containers
docker run -it \
-e POSTGRES_USER="root" \
-e POSTGRES_PASSWORD="root" \
-e POSTGRES_DB="ny_taxi" \
-v $(pwd)/ny_taxi_postgres_data:/var/lib/postgresql/data \
-p 5432:5432 \
--network=pg-network \
--name pg-database \
postgres:13
docker run -it \
-e PGADMIN_DEFAULT_EMAIL="admin@admin.com" \
-e PGADMIN_DEFAULT_PASSWORD="root" \
-p 8080:80 \
--network=pg-network \
--name pgadmin-2 \
dpage/pgadmin4
✅ You should now be able to get to and log in to the front end at http://localhost:8080/

Create New Server
Make sure your container is running and head to http://localhost:8080/. After entering the username and password as discussed above, we will want to add a 'Server'
⚒️ The UI for PgAdmin 4 has changed. Right click on 'Servers', Click 'Register', Click 'Server'.
General Tab - Name = 'Docker Localhost'

✅ Now we should have a new server in local host 8080 that is connected to our dataset in 5432
Resources
View the above docker run commands in my github repo
Last updated