Docker: MySQL, MariaDB, PostgreSQL

docker-compose.yml

version: '3.4'

services:
  mysql:
    image: mysql:latest
    container_name: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: test_db
      MYSQL_USER: test
      MYSQL_PASSWORD: test
    ports:
      - 3306:3306
    volumes:
      - mysql_db_data_container:/var/lib/mysql:rw
      - ${PWD}/docker/mysql/initdb_sql_scripts:/docker-entrypoint-initdb.d/:ro
      - ${PWD}/docker/mysql/mysql.conf:/etc/mysql/conf.d
    healthcheck:
      test: "/usr/bin/mysql --user=root --password=password --execute \"SHOW DATABASES;\""
      interval: 2s
      timeout: 20s
      retries: 10

  mariadb:
    image: mariadb:latest
    container_name: mariadb
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: test_db
      MYSQL_USER: test
      MYSQL_PASSWORD: test
    ports:
      - 3307:3306
    volumes:
      - mariadb_data_container:/var/lib/mysql:rw
      - ${PWD}/docker/mariadb/initdb_sql_scripts:/docker-entrypoint-initdb.d/:ro
      - ${PWD}/docker/mariadb/mariadb.conf:/etc/mysql/conf.d

  postgres:
    image: postgres:latest
    container_name: postgres
    restart: always
    environment:
      POSTGRES_DB: test_db
      POSTGRES_USER: test
      POSTGRES_PASSWORD: test
    ports:
      - 5432:5432
    volumes:
      - postgres_db_data_container:/var/lib/postgresql/data:rw
      - ${PWD}/docker/postgres/initdb_sql_scripts:/docker-entrypoint-initdb.d:ro
      - ${PWD}/docker/postgres/postgres.conf:/etc/postgresql/postgresql.conf

volumes:
  mysql_db_data_container:
  mariadb_data_container:
  postgres_db_data_container:
Continue reading