'My mysql container in Docker, via the feature I gave it from the dockerfile to restart itself, keeps turning itself on and off

My mysql container in docker, via the feature I gave it from the dockerfile to restart itself, keeps turning itself on and off after I attempted the docker-compose up --build command.

My Dockerfile contains several containers, including an apache, a mysql with a volume to save the data of a database and a php.

I ran into this problem as I was carrying out various tests since I had just created the volume and I wanted to see if the database was not losing the data inside it.

After various commands of docker-compose down and docker-compose up it happened that the mysql container did not work anymore, not even after other commands docker-compose down and docker-compose build --no-cache.

below i added my docker.compose.yml

all versions of the images and data for the database are taken from the various dockerfiles


version: "3.2"
services:
  php:
   build: 
    context: './php/'
    args:
     PHP_VERSION: ${PHP_VERSION}
   networks:
    - backend
   volumes:
    - ${PROJECT_ROOT}/:/var/www/html/
   container_name: php
apache:
  build:
    context: './apache/'
    args:
     APACHE_VERSION: ${APACHE_VERSION}
  depends_on:
    - php
    - mysql
  networks:
    - frontend
    - backend
  ports:
    - "80:80"
  volumes:
    - ${PROJECT_ROOT}/:/var/www/html/
  container_name: apache
mysql:
  image: mysql:${MYSQL_VERSION:-latest}
  restart: always
  ports:
    - "3306:3306"
  volumes:
        - data:/var/lib/mysql
  networks:
    - backend
  environment:
    MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
    MYSQL_DATABASE: "${DB_NAME}"
    MYSQL_USER: "${DB_USERNAME}"
    MYSQL_PASSWORD: "${DB_PASSWORD}"
  container_name: mysql   networks:
  frontend:
   backend:
  volumes:
   data:

Anyone can describe me what I can do in this case in order not to lose the progress made so far within the database since doing a little research they tell me that the volume and the image of mysql may have been corrupted?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source