How to Run PostgreSQL and pgAdmin using Docker

I’m writing this blog post to my future self. I’m sure that I will need this docker-compose.yml again.

Luca
1 min readFeb 28, 2021

Today I needed to create a simple database to store some data. I decided to try PostgreSQL.
Cause I’m a bit intrigued by Docker, I decided to run it through a container.

Photo by Jan Antonin Kolar on Unsplash

At first, I used a docker-compose which I found online, everything worked but I had to interact with the database through the command line.

I searched for a different solution and I found pgAdmin.I decided to use pgAdmin and I had to find again a way to dockerize it.
I found a docker-compose file online but I had some troubles when I tried to upload a .csv to populate my DB.
It was impossible to upload the file through a drag and drop or to select a file outside the container.

In the end, I had to change the docker-compose file adding the volume attribute.
The following one is a working docker-compose:

--

--

Luca

Computer Science student 🎓👨🏻‍💻🎧