MariaDB in Docker for local development

A database for the project that you can throw away and recreate in a second.

SNP 039 #952 Filed docker sql mariadb

A compose.yaml next to the project:

yaml
services:
  db:
    image: mariadb:11
    environment:
      MARIADB_ROOT_PASSWORD: root
      MARIADB_DATABASE: shop
      MARIADB_USER: shop
      MARIADB_PASSWORD: shop
    ports:
      - '3306:3306'
    volumes:
      - db-data:/var/lib/mysql

volumes:
  db-data:

Then:

shell
docker compose up -d
docker compose exec db mariadb -u shop -pshop shop

docker compose down -v drops the volume too, which is the fastest way to get a clean database again.