Skip to main content

How to Set Up PgAdmin and Adminer Using Docker Compose?

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


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

2) MySQL and Adminer

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
MySQL - MySQL Workbench 

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:
  1. No Manual Installation,
  2. Keeps My System Clean,
  3. Easy Portability,
  4. Faster Setup for Development
  5. Easier Updates,
  6. Better for Learning and Testing and 
  7. Works Well with Database Containers
So I will set up PgAdmin for PostgreSQL and Adminer for MySQL

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 directory
cd docker_postgre_pgadmin

# Pull and download the required container images
docker compose pull

# Create and start the containers
docker 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 down

3) 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 directory
cd docker_postgre_pgadmin

# Pull and download the required container images
docker compose pull

# Create and start the containers
docker 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/

If I need to stop the containerising of the Docker command, as follows:
docker compose down

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.


Comments

Popular Posts

How to Design a Location Tracking Module for Desktop Business Systems Using Python?

This tutorial will show you how to create an interactive map application that allows users to input geographic coordinates and visualize locations on an interactive map using Python's Tkinter GUI framework enhanced with TTKBootstrap styling and the TkinterMapView widget.  Prerequisite: This tutorial is part of the standalone tutorial. 📚 View the  standalone tutorial Preliminary   Before I begin, it is recommended to activate the virtual environment before installing the relevant dependencies. python -m venv venv venv\Scripts\activate pip install ttkbootstrap tkintermapview As usual, we need to import the relevant module and set the root values from tkinter import * import ttkbootstrap as tb import tkintermapview from ttkbootstrap.dialogs import Messagebox root = tb.Window(themename='darkly') root.title('Find My Map') root.geometry("1200x1200") I would like to divide it into three sections.  a) Input Panel Layout,  The headers are mainly a label...

How to Create Flask Forms with CKEditor and Flask-WTF?

In this tutorial, we will be integrating Flask-WTF and Flask-CKEditor into your Flask application! You'll learn how to set up the editor, securely handle formatted HTML content, and create a seamless user experience that enhances any project that requires user-generated content. Let's get started! Prerequisite: This tutorial is part of the Flask CKEditor Project Series. 📚 View the Complete Flask CKEditor Series                                                                                                                                                  ➡ Next Part Preliminary Before I begin, it is recommended to activate the v...

How to Store Application Data with SQLite in Python?

  In the previous tutorial, I used TinyDB as our storage solution to keep application data in a simple JSON-based format. While TinyDB is lightweight and easy to use, many web applications require a more structured and scalable database system. In this tutorial, we will switch to SQLite , a powerful relational database that integrates well with Python and web frameworks. By using SQLite, you will learn how to store, manage, and query data in a more structured way for real-world applications. Prerequisite: This tutorial is part of the Flask CKEditor Project Series. 📚 View the Complete Flask CKEditor Series ⬅ Previous Part                                                                                                         ...