composebuilder

Docker Compose: MariaDB 11.4 LTS + Adminer 5

Docker Compose stack with MariaDB 11.4 LTS, a healthcheck, a named volume and Adminer 5 on localhost. A lightweight admin UI for MySQL-compatible databases.

When to use this stack

MariaDB is a community fork of MySQL with a compatible protocol, many of the same commands and a strong record in web hosting, WordPress and self-hosted applications. This stack runs MariaDB 11.4 LTS with a healthcheck and a named volume, and adds Adminer 5, a single-file web interface for browsing tables, running SQL and exporting data. The combination is small, quick to start and easy to keep running on a modest VPS.

Use this stack for a single-server application, for a local development database that should behave like MariaDB in production, or when you want an admin screen that uses little memory. Do not use it as a high availability design. A single MariaDB container has no automatic failover, so you still need scheduled backups and a tested restore procedure, or a replicated cluster if downtime is not acceptable. Also keep port 3306 private. The Adminer port is the only one published, and it is bound to 127.0.0.1 so that it is reachable only from the host itself or through an SSH tunnel.

docker-compose.yml

services:
  mariadb:
    image: mariadb:11.4
    restart: unless-stopped
    environment:
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
      MARIADB_DATABASE: ${MARIADB_DATABASE}
      MARIADB_USER: ${MARIADB_USER}
      MARIADB_PASSWORD: ${MARIADB_PASSWORD}
    volumes:
      - mariadb_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 60s

  adminer:
    image: adminer:5.4.1
    restart: unless-stopped
    environment:
      ADMINER_DEFAULT_SERVER: mariadb
    ports:
      - "127.0.0.1:8082:8080"
    depends_on:
      mariadb:
        condition: service_healthy

volumes:
  mariadb_data:

.env

.env
# Root password, used for administration only
MARIADB_ROOT_PASSWORD=CHANGE_ME_ROOT_PASSWORD

# Application database and its dedicated user
MARIADB_DATABASE=app_db
MARIADB_USER=app_user
MARIADB_PASSWORD=CHANGE_ME_APP_PASSWORD

Start and verify

Source the file into your shell only for the verification commands. Compose reads .env automatically. Wait until the mariadb service reports healthy before you try to log in through Adminer, because the first initialization can take a minute.

Shell
set -a; . ./.env; set +a
docker compose config --quiet
docker compose up -d
docker compose ps
docker compose logs --tail=50 mariadb
docker compose exec mariadb mariadb -u "$MARIADB_USER" -p"$MARIADB_PASSWORD" -e "SELECT VERSION();" "$MARIADB_DATABASE"
curl -s -o /dev/null -w "Adminer HTTP status: %{http_code}\n" http://127.0.0.1:8082/

Production checklist

  • Replace every CHANGE_ME value with a long random password, and use the root account only for administration.
  • Keep port 3306 unpublished. Applications connect through the Compose network using the host name mariadb.
  • Give each application its own database and user, with grants limited to that database.
  • Schedule mariadb-dump backups, store them off the server and run a restore test regularly.
  • Set a memory limit on the container and tune innodb_buffer_pool_size through the command section.
  • Keep Adminer on localhost behind an SSH tunnel or behind a TLS proxy with access control, and stop the container when it is not needed.
  • Pin the image to the 11.4 line and apply minor updates after reading the release notes.
  • Monitor free disk space, because a full disk stops the server from writing data.

Common problems

  • Symptom: Adminer reports an access denied error for the application user. Cause: the user name or password in the login form does not match the .env values, or the variables were changed after the first start. Fix: use the values from .env. If you changed them later, update the account inside MariaDB with ALTER USER.

  • Symptom: the mariadb container stays unhealthy for a long time after the first start. Cause: the healthcheck runs before the initialization finishes. Fix: check docker compose logs mariadb. Increase start_period if the host is slow, and make sure the disk is not nearly full.

  • Symptom: the Adminer server field shows localhost and the connection fails. Cause: inside the Adminer container, localhost points to Adminer itself. Fix: set the server to mariadb, which the ADMINER_DEFAULT_SERVER variable already does.

  • Symptom: the browser cannot open port 8082 from another computer. Cause: the port is bound to 127.0.0.1 by design. Fix: open an SSH tunnel with ssh -L 8082:127.0.0.1:8082 user@your-server, then browse to http://localhost:8082.

Variations

  • MySQL instead of MariaDB: the MySQL stack in this category has the same layout. Change the image and the variable names to the MYSQL_ prefix.
  • phpMyAdmin instead of Adminer: use it when you need more administration features, and keep the same port binding rules.
  • Dedicated backup container: add a small container that runs mariadb-dump on a schedule and writes to a mounted backup directory.

Questions

Why use Adminer instead of phpMyAdmin?

Adminer is a single PHP file in one container with a small footprint and support for several database engines. phpMyAdmin has more administration features. Both connect to MariaDB without changes to the database.

Why is the server name already filled in on the Adminer login screen?

The ADMINER_DEFAULT_SERVER variable sets mariadb as the default server, which is the Compose service name. You still enter the database user and password from your .env file.

Why does the MariaDB container need several minutes on its first start?

The first start creates the data directory, the root account, the application database and the application user. The healthcheck waits until the server accepts connections before Adminer starts.

Is MariaDB 11.4 a long-term support release?

Yes. MariaDB 11.4 is an LTS series, so it receives security fixes for a longer period than short-term releases. Check the MariaDB lifecycle page before choosing a version for a long-lived project.

Adapt this stack

Load these files into the builder to rename services, change ports, add a cache or a proxy, and generate fresh passwords for the .env.

Open in builder
  • ClickHouse 25.8 Analytics Database

    Docker Compose stack for ClickHouse 25.8 with a dedicated user, a healthcheck, raised file limits and HTTP and native ports on localhost for analytical queries.

    • clickhouse
    Difficulty: Advanced
  • Elasticsearch 8 + Kibana Search Stack

    Docker Compose stack for Elasticsearch 8.19 and Kibana 8.19 with security enabled, a persistent volume, a healthcheck and localhost-only ports.

    • elasticsearch
    • kibana
    Difficulty: Advanced
  • FastAPI + MongoDB 7 + Mongo Express

    Docker Compose stack for a Python FastAPI API on MongoDB 7 with authentication, a healthcheck, persistent storage and a protected Mongo Express UI on localhost.

    • api
    • mongodb
    • mongo-express
    Difficulty: Intermediate
  • Meilisearch v1 + Python FastAPI Search API

    Docker Compose stack for Meilisearch v1 in production mode with a master key, a healthcheck and persistent data, plus a FastAPI search API on localhost.

    • meilisearch
    • api
    Difficulty: Intermediate

Browse more Databases & Search stacks or the full library.