If you are new to database management with Docker, this tutorial will guide you through setting up both PgAdmin and Adminer using Docker containers. By containerising these tools, you can quickly launch lightweight and portable database management environments without installing them directly on your operating system. This approach also makes it easier to manage configurations, updates, and multiple projects across different devices.
Prerequisite:This tutorial is part of the Docker Series.
📚 View the Complete Docker Series
PostgreSQL Use case in
(i) Flask app
(ii) Python automation
Preliminary:
In this tutorial, I will walk you through how to download and install Docker and set up PgAdmin and Adminer using Docker Compose.
The file and folder for both containers are as follows:
1) PostgreSQL and PgAdmin
In the previous tutorial, I largely used SQLite as a database; however, SQLite is a lightweight database, and it may not be suitable for concurrent access by multiple users, especially in a web app. Therefore, more industry-based databases will be applied, which are PostgreSQL and MySQL databases.
What are MySQL and PostgreSQL?
MySQL and PostgreSQL are both popular open-source relational database management systems (RDBMS). They are used to store, organise, manage, and retrieve data for websites, applications, and software systems.
PostgreSQL - Supports advanced data types, JSON, GIS, and powerful indexing and is preferred for applications requiring strong data integrity and scalability.
MySQL - Known for being beginner-friendly and fast. Common in blogging platforms and web hosting environments,
Where and how to download and install both SQL tools?
In fact, I can directly download and install the respective tools as a desktop GUI to access both databases, such as the following:
PostgreSQL - PostgreSQL PgAdmin
However, I will use Docker to set up both databases.
Why use Docker to set up PgAdmin and Adminer?
By using Docker, I can derive the following benefits:
- No Manual Installation,
- Keeps My System Clean,
- Easy Portability,
- Faster Setup for Development
- Easier Updates,
- Better for Learning and Testing and
- Works Well with Database Containers
1) Download and Install Docker
Docker is a platform designed to help developers build, share, and run container applications.
Since Docker is an isolated container, if I need a single service, I write a Dockerfile; meanwhile, if I need multiple services, I use a Docker Compose YAML file.
First, I need to download and install desktop Docker. It has multiple OSs to choose from, including Windows OS, Mac OS, and Linux OS. Since I used Windows 11, I downloaded the Windows OS, and I need to follow the step-by-step instructions to install Docker on the desktop.
Before containerising the images, I need to open the Docker Desktop.
2) Set up and configure the PostgreSQL and PgAdmin
Then, the Docker Compose
YAML file helps to define and manage multiple Docker containers in one place, and in my case, it contains two services: one is PostgreSQL, and the other is PgAdmin, as shown below:name: PostgreSQL
services:
postgres:
image: postgres:16
container_name: postgres_db
restart: always
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
POSTGRES_DB: mydb
ports:
- "5432:5432"
pgadmin:
image: dpage/pgadmin4:latest
container_name: pgadmin
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: admin123
ports:
- "8080:80"
To run the Docker container, first open a bash terminal, navigate to the file directory, and execute the Docker command line below:
# Access the project directorycd docker_postgre_pgadmin# Pull and download the required container imagesdocker compose pull# Create and start the containersdocker compose up
Once the container is running, I will go ahead and launch the browser and key in the URL and the web contents as follows:
http://localhost:8080/
If I need to stop the containerising of the Docker command, as follows:
docker compose down3) Set up and configure the MySQL and Adminer
In fact, the same process also applies to MySQL and Adminer, except the Docker Compose YAML is now different and shown as below:
name: MySQL
services:
db:
image: mysql:8.0
container_name: mysql_db
restart: always
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: mydb
MYSQL_USER: myuser
MYSQL_PASSWORD: mypass
ports:
- "3307:3306" # Host port changed to 3307
volumes:
- db_data:/var/lib/mysql
adminer:
image: adminer
container_name: adminer_ui
restart: always
ports:
- "9000:8080" # Adminer on port 9000
environment:
- ADMINER_DEFAULT_SERVER=db
depends_on:
- db
volumes:
db_data:To run the Docker container, first open a bash terminal, navigate to the file directory, and execute the Docker command line below:
# Access the project directorycd docker_postgre_pgadmin# Pull and download the required container imagesdocker compose pull# Create and start the containersdocker compose up
Once the container is running, I will go ahead and launch the browser and key in the URL and the web contents as follows:
http://localhost:9000/Final Wrap-up:
In this tutorial, you learned how to quickly deploy PgAdmin and Adminer using Docker containers for a cleaner, more portable, and beginner-friendly database management setup. With Docker, you can simplify installation, reduce system clutter, and create reusable environments for development and testing. Whether you are managing MySQL or PostgreSQL databases, containerising your tools helps streamline your workflow and makes database administration much more convenient.
Published: May 2026
Last Updated: May 2026
About the Author
Kelvin Loh is a Python developer focused on Flask, desktop applications, and business automation solutions. He shares practical tutorials and real-world coding projects to help developers and small businesses build useful applications.
.png)





Comments
Post a Comment