Kitloft

All tools / Docker Compose examples

MariaDB with Docker Compose

MariaDB with a named volume, the image's built-in health check and the port published only on localhost.

Customize names, versions and passwords →

compose.yaml
services:
  mariadb:
    image: mariadb:11.4
    restart: unless-stopped
    environment:
      MARIADB_ROOT_PASSWORD: "change-me"
      MARIADB_DATABASE: "app"
      MARIADB_USER: "app"
      MARIADB_PASSWORD: "change-me"
    volumes:
      - mariadb-data:/var/lib/mysql
    ports:
      - "127.0.0.1:3306:3306"
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 10

volumes:
  mariadb-data:

Passwords here are placeholders (change-me). The generator creates random ones for you.

How to use it

Commands
docker compose up -d
docker compose ps
docker compose logs -f

Prefer Kubernetes? See the MariaDB Kubernetes version.