How to deploy Adminer 4.8.1 – Database Mgmt Tool in docker swarm behind Traefik v2.0

How to deploy Adminer 4.8.1 – Database Mgmt Tool in docker swarm behind Traefik v2.0

Adminer is a database management tool with a beautiful GUI who wants to use GUI instead of Console.

I am deploying Adminer 4.8.1, a database management tool using Docker Compose to manage databases using GUI. I deployed MariaDB in the previous post and showed how to manage it using Console. Some of us like GUI instead of Console. So this post is for the people who like to manage databases using GUI.

Adminer is a database management tool with a beautiful GUI who wants to use GUI-based database administration instead of Console.

I am deploying Adminer 4.8.1, a database management tool using Docker Compose to manage databases using GUI. I deployed MariaDB in the previous post and showed how to manage it using Console. Some of us like GUI instead of Console. So this post is for the people who like to manage databases using GUI.

Let’s start with actual deployment…

Prerequisites

Please make sure you should fulfill the below requirements before proceeding to the actual deployment.

  1. Docker Swarm Cluster with GlusterFS as persistent tool.

  2. Traefik as reverse proxy to expose micro-services to external.

  3. Database stack to host application databases.

Introduction to Adminer

Adminer ( formerly phpMinAdmin) is a database management tool with a beautiful GUI who want to use GUI instead of Console. We can use it for managing content in MySQLMariaDBPostgreSQLMS SQLSQLiteOracleFirebirdSimpleDBElasticsearch, and MongoDB. Adminer is distributed under Apache license (or GPL v2) in a form of a single PHP file (around 470 KB in size).

Why is Adminer

phpMyAdmin is one of the most famous tools for managing the MySQL database. However, it is not perfect which is the reason why Adminer has been created. The most important differences are:

  • User experience

  • Supported MySQL features

  • Performance

  • Security

Adminer Features

  • Connect to a database server with username and password

  • Select an existing database or create a new one

  • List fields, indexes, foreign keys, and triggers of table

  • Change name, engine, collation, auto_increment, and comment of table

  • Alter name, type, collation, comment, and default values of columns

  • Add and drop tables and columns

  • Create, alter, drop and search by indexes including full text

  • Create, alter, drop and link lists by foreign keys

  • Create, alter, drop and select from views

  • Create, alter, drop and call stored procedures and functions

  • Create, alter and drop triggers

  • List data in tables with search, aggregate, sort, and limit results

  • Insert new records, update and delete the existing ones

  • Supports all data types, blobs through file transfer

  • Execute any SQL command from a text field or a file

  • Export table structure, data, views, routines, databases to SQL or CSV

Please go through the below link for the full features of Adminer.

https://www.adminer.org/en/phpmyadmin/

Prepare Adminer Environment

Create a folder in /opt directory to place configuration file, i.e, .yml file for Adminer.

Use the below commands to create the folder.

cd /opt
sudo mkdir -p adminer
cd adminer
sudo touch adminer.yml

Adminer Docker Compose

Open adminer.yml created earlier with nano editor using sudo nano adminer.yml

Copy and paste the below code in adminier.yml

Here is the docker compose file for adminer.

version: "3.7"

services:
  adminer:
    depends_on:
      - testdb
    image: adminer
    ports:
      - '5000:8080'
    environment:
      - PMA_HOST=testdb:3306
      - MYSQL_USER=testuser
      - MYSQL_PASSWORD=password
    networks:
      - proxy
    deploy:
      placement:
        constraints: [node.role == worker]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=proxy"
        - "traefik.http.routers.adminer.rule=Host(`dbadmin.example`)"
        - "traefik.http.routers.adminer.tls=true"
        - "traefik.http.routers.adminer.tls.certresolver=default"
        - "traefik.http.routers.adminer.entrypoints=websecure"
        - "traefik.http.services.adminer.loadbalancer.server.port=8080"
networks:
  proxy:
    external: true

Tip

Please watch the below video to deploy Adminer Database Administration Tool.


We need to map port 8080 to 5000 (any internal port) because port 8080 is used by traefik dashboard. That’s why we have to map it to internal IP address in configuration file.

I used Traefik stack that was deployed (proxy stack) earlier to Docker Swarm Cluster as a reverse proxy / load balancer.

Also proxy docker overlay network for the application to be accessible externally.

Deploy Adminer using Docker Compose

Now it’s time to deploy our docker-compose file above adminer.yml using the below command

docker stack deploy --compose-file adminer.yml adminer

You can give it any name for the stack. I just named it as adminer

Check the status of the stack by using docker stack ps adminer

Now log into adminer interface by using URL in the configuration file, dbadmin.example.com (replace example.com with your domain name)

Make sure that you have DNS entry for your application (dbadmin.example.com) in your DNS Management Application.

Now log into it using the server name, username, and password

[Adminer Login Window] [Adminer Dashboard]

We can do a lot of database management tasks using Adminer smartly.

  1. Creating a table is smart as Adminer adds fields automatically

  2. Edit tables, reorganize columns, and add them in different places at once

  3. Adminer offers a foreign keys interface directly in create as well as alter table

In the coming posts, I will show you how to deploy the most popular applications that are used in our day-to-day activities. WordPress, Rocker Chat, Wekan, Nextcloud, Flarum, Dolibarr ERP, Metabase, and many more to our Docker Swarm Cluster behind Traefik with Letsencrypt. Stay tuned… 🙂