3

When I use docker swarm with MySQL I met with problem (If docker container rerun mysql data will disappear)

I spend a lot of time to search how to fix this problem, use volume store data and use glusterFs across host share volume but experiencing database data inconsistency.

Is my method right ? or can someone tell we how to fix this problem?

At last , This is my example yaml file :

version: '3.8'
services:
  www:
    image: httpd:latest
    ports: 
    - "8001:80"
    volumes:
    - /usr/papertest/src:/var/www/html/  
  

  db:
    image: mariadb:latest
    restart: always
    volumes:
    - /usr/test/src:/docker-entrypoint-initdb.d
    - /etc/timezone:/etc/timezone:ro
    - /usr/test/backup:/var/lib/mysql  #/usr/test/backup is  glusterfs mount place

    environment: 
      MYSQL_ROOT_PASSWORD: MySQL_PASSWORD
      MYSQL_DATABASE: MYSQL_DATABASE
      #MYSQL_USER: MYSQL_USER
     # MYSQL_PASSWORD: MYSQL_PASSWD

    

  phpmyadmin:
    image: phpmyadmin
    #restart: always
    ports:
    - 4567:80
    environment:
    - PMA_ARBITRARY=1
Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
William
  • 31
  • 1

0 Answers0