apache2 php and phpmyadmin docker compose code example

Example: docker-compose phpmyadmin example

version: '3.8'
services:
#############################
# MARIADB SERVIVICES
#############################
  db:
    image: mariadb:latest
    restart: always
    healthcheck:
      interval: 120ms
      retries: 5
      start_period: 60ms
      test: |
        touch /tmp/healthcheck.txt &&
        mkdir /tmp/healthcheck &&
        mv /tmp/healthcheck.txt /tmp/healthcheck &&
        cd /tmp/healthcheck &&
        echo "hello my docker container is working fine" >> healthcheck.txt &&
        cat healthcheck.txt &&
        rm healthcheck.txt &&
        cd .. &&
        rmdir /tmp/healthcheck
        cls
      timeout: 30ms
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_USER=root
      - MYSQL_DATABASE=projectdb
    ports:
      - 3306:3306
    volumes:
      - mysql-data:/var/lib/mysql/data
    networks:
      - pma_networks
#############################
# PHPMYADMIN SERVIVICES
#############################
  pma:
    image: phpmyadmin:latest
    restart: always
    healthcheck:
      interval: 120ms
      retries: 5
      start_period: 60ms
      test: |
        touch /tmp/healthcheck.txt &&
        mkdir /tmp/healthcheck &&
        mv /tmp/healthcheck.txt /tmp/healthcheck &&
        cd /tmp/healthcheck &&
        echo "hello my docker container is working fine" >> healthcheck.txt &&
        cat healthcheck.txt &&
        rm healthcheck.txt &&
        cd .. &&
        rmdir /tmp/healthcheck
        cls
      timeout: 30ms
    environment:
      - PMA_ARBITRARY=1
    ports:
      - 80:80
    depends_on:
      - db
    volumes:
      - pma-data:/var/lib/phpmyadmin/data
    networks:
      - pma_networks
#############################
# PERSISTENT DATA
#############################
volumes:
  mysql-data:
  pma-data:
################################
# SAME NETWORKS FOR ALL SERVICE
###############################
networks:
  pma_networks:

Tags:

Php Example