does anyone have any idea about this error? I am trying to deploy a swarm stack with mysql:8 image and I got this error the MySQL service stopped and not started. kindly check the DB service below
version: "3.7"
services:
app:
image: 127.0.0.1:5000/app
working_dir: /var/www/html
volumes:
- ./:/var/www/html
networks:
- backend
deploy:
replicas: 5
restart_policy:
condition: on-failure
db:
image: mysql:8
environment:
MYSQL_DATABASE: ROUTE
MYSQL_ROOT_PASSWORD: 2020
MYSQL_PASSWORD: 2020
MYSQL_USER: sqluser
volumes:
- db:/var/lib/mysql
networks:
- backend
deploy:
replicas: 3
restart_policy:
condition: on-failure
networks:
backend:
frontend:
driver: overlay
volumes:
db:
CodePudding user response:
Having multiple instances of MySQL trying to write to the same database on disk is asking for trouble. That's why the first instance you start locks a file on the disk, so any subsequent instances will fail.
It's by design that what you're doing fails.
CodePudding user response:
The problem seems to be the volume:
volumes: db:
You dont have any defined. I use something like this:
volumes: db-data: driver: local
Good luck