数周以来,我一直在使用此映像进行卷挂载,没有任何问题。现在突然之间,如果我尝试挂载一个卷(ANY卷),则该容器会打印一些基本的启动日志并退出。
该应用程序本身不提供错误指示,因此这似乎是docker本身在挤压东西。
这就是我所拥有的:
Docker版本(Mac上为原生):
$ docker -v
Docker version 17.09.0-ce, build afdb6d4
本地目录:
$ ls
1 Dockerfile README.md Schema dba_utilities docker-compose.yml docs
启动一个MYSQL容器:
$ docker run -d -v $PWD/Schema:/root:ro -v $PWD/dba_utilities:/tmp:ro -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5.6
aa213c8cb28ea2f75e3064b296db6e5e450466cc45e60a7de3f21a2ca98987f4
现在证明它已经死了:
$ docker ps -a | head -3
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aa213c8cb28e mysql:5.6 "docker-entrypoint..." 23 seconds ago Exited (141) 21 seconds ago inspiring_curie
cc43d27b29cf mysql:5.6 "docker-entrypoint..." 4 minutes ago Exited (141) 4 minutes ago laughing_shaw
现在显示容器日志:
$ docker logs aa213c8cb28ea2f75e3064b296db6e5e450466cc45e60a7de3f21a2ca98987f4
Initializing database
2017-10-02 18:31:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-02 18:31:00 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-10-02 18:31:00 0 [Note] /usr/sbin/mysqld (mysqld 5.6.37) starting as process 36 ...
但是,如果我尝试从具有相同卷的相同映像启动外壳,那么一切看起来都不错:
$ docker run -it -v $PWD/Schema:/root:ro -v $PWD/dba_utilities:/tmp:ro -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5.6 /bin/bash
root@898fe2f883a2:/# cd
root@898fe2f883a2:~# ls
README.md db1 db2
root@898fe2f883a2:~# ls /tmp
README.md apply.sh dump_all.sh pullschema.sh schemata.txt
root@898fe2f883a2:~# pwd
/root
root@898fe2f883a2:~# exit
现在,如果我卸下卷挂载:
$ docker run -d -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5.6
98b51f96fe482cfd0453a0eb4ff8b9d1f2729244ad2316e245680ce4976a200d
并检查状态:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
98b51f96fe48 mysql:5.6 "docker-entrypoint..." 4 seconds ago Up 3 seconds 3306/tcp nervous_mcnulty
它正在运行。从日志验证:
docker logs 98b51f96fe482cfd0453a0eb4ff8b9d1f2729244ad2316e245680ce4976a200d
Initializing database
2017-10-02 18:36:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-02 18:36:48 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-10-02 18:36:48 0 [Note] /usr/sbin/mysqld (mysqld 5.6.37) starting as process 36 ...
2017-10-02 18:36:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-02 18:36:53 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-10-02 18:36:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.37) starting as process 59 ...
Database initialized
MySQL init process in progress...
2017-10-02 18:36:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-02 18:36:56 0 [Note] mysqld (mysqld 5.6.37) starting as process 87 ...
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
MySQL init process done. Ready for start up.
2017-10-02 18:36:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-02 18:36:59 0 [Note] mysqld (mysqld 5.6.37) starting as process 1 ...
过去,即使卷安装有问题,它也可能立即出错,或者我没有安装但不是这样。
我也在ubuntu 14.04 VM上尝试了同样的结果
最佳答案
这里的解决方案是从mount和env变量寻址中删除只读标志,它对我有用,并且我能够在Docker version 17.06.1-ce, build 874a737
上重现您的错误,所以它看起来像是一个更广泛的问题,我尝试省略两个env变量的使用和:ro标志,没有一个起作用,只有不使用两个都起作用
docker run -d -v Schema:/root -v dba_utils:/tmp -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5.6