docker phpmyadmin and mysql code example

Example 1: phpmyadmin docker tutorial

$ docker pull phpmyadmin/phpmyadmin:latest

Example 2: docker phpmyadmin

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:

Misc Example