Hi and thanks in advance,
I am trying to use mysqldump to backup the data in a MySQL docker container. I was following the docs here:
https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-more-topics.html#docker-mysqldump
I can't copy the instructions exactly because my docker container has its data in a volume (rather than a bind) mount. However I could not see why this would make any difference. I am running two docker containers using docker compose, with the following docker compose file (with irrelevant info removed):
```services:
mysql:
image: 'mysql:8.2.0'
environment:
MYSQL_DATABASE: 'myDb'
MYSQL_ROOT_PASSWORD: 'root'
ports:
- '3306'
networks:
- net1
volumes:
- dataVol:/var/lib/mysql:rw
mysql-backup:
image: 'mysql:8.2.0'
entrypoint: mysqldump -u root --password root --databases myDb --add-drop-database > /path/to/backup.sql
environment:
MYSQL_ROOT_PASSWORD: 'root'
networks:
- net1
ports:
- '3307'
volumes:
- dataVol:/var/lib/mysql:rw
volumes:
dataVol:
driver: local
networks:
net1:
driver: bridge
```
I first then ran (docker compose up) the mysql service (and it works correctly). But then when I run the backup job (docker compose run) I get the error:
`[ERROR] [MY-012574] [InnoDB] Unable to lock ./ibdata1 error: 11`
Upon a Google, this appears to occur when two MySQL instances are working with the same data directory which apparently we should never be doing. Eg the MySQL docs here suggest we shouldn't do this:
https://dev.mysql.com/doc/refman/8.0/en/multiple-data-directories.html
So I am now confused because it seems that the MySQL docs are contradicting themselves... Or did I somehow do something different (by using a volume not a bind mount) that is causing my error?