--- name: mariadb networks: mariadb_net: attachable: true internal: true external: false name: mariadb driver: bridge ipam: driver: default config: - subnet: 172.20.16.0/24 ip_range: 172.20.16.0/24 gateway: 172.20.16.1 driver_opts: com.docker.network.bridge.default_bridge: "false" com.docker.network.bridge.enable_icc: "true" com.docker.network.bridge.enable_ip_masquerade: "true" com.docker.network.bridge.host_binding_ipv4: "0.0.0.0" com.docker.network.bridge.name: "mariadb" com.docker.network.driver.mtu: "1500" labels: com.mariadb.network.description: "is an isolated bridge network." services: mariadb_db: deploy: resources: limits: pids: 2048 # Limits the number of processes and threads (fork bomb protection). restart: always logging: driver: "json-file" options: max-size: "1M" max-file: "2" stop_grace_period: 1m container_name: mariadb_db image: docker.io/mariadb:13.1.2@sha256:396c449ce655b679f6abca2ecbcf7c2dfe1df233b3f22d83f2db17d5fcd1006c pull_policy: if_not_present volumes: - /docker/mariadb/config/my.cnf:/etc/my.cnf - /docker/mariadb/production/db:/var/lib/mysql - /sys/fs/cgroup/memory.pressure:/sys/fs/cgroup/memory.pressure env_file: # Compose loads each file that exists and skips a missing one: # '.env' for the Docker Compose CLI, 'stack.env' for Portainer. - path: .env required: false - path: stack.env required: false environment: PUID: "1000" PGID: "1000" TZ: Europe/Amsterdam # Adjust the timezone to match your local timezone. You can find the full list of timezones here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. MARIADB_ROOT_PASSWORD: ${ROOT_PASSWORD_DB} # Fill in the value in both the .env and stack.env files hostname: mariadb_db networks: mariadb_net: ipv4_address: 172.20.16.2 ports: - target: 3306 # container port host_ip: 127.0.0.1 # The Host IP mapping, unspecified means all network interfaces (0.0.0.0) published: 3306 # publicly exposed port protocol: tcp # tcp or udp mode: ingress # host: For publishing a host port on each node security_opt: - no-new-privileges:true labels: com.mariadb.db.description: "is a MariaDB database." healthcheck: disable: false test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s timeout: 5s retries: 3 start_period: 10s start_interval: 5s