我有一个docker-compose.yml文件,包含以下内容:
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:
填充的\u db容器成功启动,并用test\u database.sql的内容填充数据库。但是,完成此操作后,db容器将启动并尝试将填充的\u test \u db用作其/var/lib/mysql,从而导致以下错误:
Unable to lock ./ibdata1 error: 11
Check that you do not already have another mysqld process using the same InnoDB data or log files.
这可能是因为填充的\u db容器仍在运行。如何在填充卷后停止它的运行,以便db容器可以使用填充的卷?
暂无答案!
目前还没有任何答案,快来回答吧!