I have a docker-compose.yml file with the following:
populated_db:
container_name: populated_db
restart: always
image: mysql
volumes:
- ./test_database.sql:/docker-entrypoint-initdb.d/a.sql
- populated_test_db:/var/lib/mysql
ports:
- "33061:3306"
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: aaaa
MYSQL_USER: aaaa
MYSQL_PASSWORD: aaaa
db:
container_name: db
image: mysql
ports:
- "33060:3306"
volumes:
- type: volume
source: populated_test_db
target: /var/lib/mysql
volume:
nocopy: false
restart: always
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: aaaa
MYSQL_USER: aaaa
MYSQL_PASSWORD: aaaa
depends_on:
- populated_db
volumes:
populated_test_db:
The populated_db container successfully starts and populates the database with the contents of test_database.sql. However, once it has done that, the db container starts and tries to use populated_test_db as its /var/lib/mysql, causing the following error:
Unable to lock ./ibdata1 error: 11
Check that you do not already have another mysqld process using the same InnoDB data or log files.
Presumably this is because the populated_db container is still running. How can I stop it running once it has populated the volume, so the db container can use the populated volume?
Aucun commentaire:
Enregistrer un commentaire