> For the complete documentation index, see [llms.txt](https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/module-1/1.2-docker-and-docker-compose/1.2.3-connecting-pgadmin-and-postgres.md).

# 1.2.3 - Connecting pgAdmin and Postgres

Last updated Jan 19, 2025

:no\_entry: I recommend not pausing your workflow once you `docker run -it` in this video

Youtube Video | \~10 min

{% embed url="<https://www.youtube.com/watch?v=hCAIVe9N0ow&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=7&pp=iAQB>" %}
<https://www.youtube.com/watch?v=hCAIVe9N0ow&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=7&pp=iAQB>
{% endembed %}

:writing\_hand: In this video we will talk about using <mark style="background-color:orange;">pgAdmin</mark>  to manage our <mark style="background-color:purple;">Postgres</mark> in <mark style="background-color:blue;">Docker.</mark> We will learn about creating a <mark style="background-color:yellow;">**network**</mark> 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 <mark style="background-color:orange;">pgAdmin</mark> to host our taxi dataset.&#x20;

:eyes: Note that in 1.2.5 we will be using docker-compose in a yaml file method instead

### pgAdmin

"<mark style="background-color:orange;">pgAdmin</mark> is an open-source, web-based graphical user interface (GUI) tool primarily used to manage and administer <mark style="background-color:purple;">PostgreSQL</mark> 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&#x20;

### Running pgAdmin & Postgres together

:black\_medium\_square: To connect the two, we need to create a network

{% embed url="<https://docs.docker.com/reference/cli/docker/network/create/>" %}

"Container networking refers to the ability for containers to connect to and communicate with each other, or to non-Docker workloads."

```bash
docker network create pg-network
```

Then we want to add the network and network name to our <mark style="background-color:blue;">docker</mark> run command for both containers

```bash
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
```

:white\_check\_mark: You should now be able to get to and log in to the front end at <http://localhost:8080/>

{% hint style="info" %}
If you stop your docker container at any point, go to your <mark style="background-color:blue;">docker</mark> desktop to restart it. You can also get to your Port(s) by clicking on them here - such as 8080:80
{% endhint %}

<figure><img src="https://3375647567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxgPnpaRKCInTeWOYlVUE%2Fuploads%2FT0A62CwhCUzubNhF2WlB%2FScreen%20Shot%202025-01-19%20at%2012.56.22%20PM.png?alt=media&amp;token=1df0c5f7-13e2-4b1b-bf61-2b5416bf2818" alt=""><figcaption></figcaption></figure>

***

### 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'

:hammer\_pick: The UI for PgAdmin 4 has changed. Right click on 'Servers', Click 'Register', Click 'Server'.

General Tab - Name = 'Docker Localhost'

<figure><img src="https://3375647567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxgPnpaRKCInTeWOYlVUE%2Fuploads%2Fd2uaITsk6343shp3aotF%2FScreen%20Shot%202025-01-19%20at%201.18.53%20PM.png?alt=media&amp;token=b83f83da-9f3b-4599-ae06-13252ee44287" alt=""><figcaption></figcaption></figure>

:white\_check\_mark: 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

{% @github-files/github-code-block url="<https://github.com/Tinker0425/de-zoomcamp-my-work/tree/master/module-01/docker/video_3>" %}

:books: [Docker networking ](https://docs.docker.com/engine/network/)

:books: [Where we are heading](mailto:undefined)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/module-1/1.2-docker-and-docker-compose/1.2.3-connecting-pgadmin-and-postgres.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
