简体   繁体   English

Mac上的Docker:无法运行MySQL

[英]Docker on Mac: Unable to run MySQL

I am using Docker very first time. 我是第一次使用Docker。 On running command: make kickoff I am getting error: 在运行命令: make kickoff我得到错误:

myapp_php_apache_engine_dev is up-to-date
Starting myapp_mysql_dev

ERROR: for mysql  Cannot start service mysql: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"process_linux.go:359: container init caused \\\"rootfs_linux.go:53: mounting \\\\\\\"/Applications/MAMP/htdocs/clients/codingmachine/myapp/mysql/custom-my.cnf\\\\\\\" to rootfs \\\\\\\"/mnt/sda1/var/lib/docker/aufs/mnt/2ab6b2578ad9f8da2d453aefa5cd9b288fee30dd2d73efc3048627cf0861d55a\\\\\\\" at \\\\\\\"/mnt/sda1/var/lib/docker/aufs/mnt/2ab6b2578ad9f8da2d453aefa5cd9b288fee30dd2d73efc3048627cf0861d55a/etc/mysql/mysql.cnf\\\\\\\" caused \\\\\\\"not a directory\\\\\\\"\\\"\"\n"
ERROR: Encountered errors while bringing up the project.
make: *** [up] Error 1

When running docker toolbox, the docker daemon runs in a VirtualBox VM. 运行docker toolbox时,docker守护程序在VirtualBox VM中运行。 The daemon (and containers, which run inside that VM) therefore don't have access to files on your host (Mac OS X). 因此,守护程序(以及在该VM中运行的容器)无权访问主机上的文件(Mac OS X)。

When you bind-mount a directory from your host into the container (so that the container can access those files), files are always mounted from the host that the daemon runs on; 当您将主机中的目录绑定安装到容器中(以便容器可以访问这些文件)时,文件总是从运行守护程序的主机上装入; in your case, the VirtualBox VM. 您的情况是VirtualBox VM。

Docker Toolbox uses a "trick" to allow you to mount files from your host; Docker Toolbox使用“技巧”来允许您从主机装载文件; files inside the /Users/ directory are shared with the VirtualBox VM using VirtualBox "guest additions". /Users/目录中的文件通过VirtualBox“来宾添加”与VirtualBox VM共享。 This means that when you run; 这意味着当您运行时;

docker run -v /Users/myname/somedir:/var/www/html -d nginx

The docker daemon mounts the /Users/myname/somedir directory from the VM into the container. 泊坞窗守护程序将VM中/Users/myname/somedir目录挂载到容器中。 Due to the guest additions "trick", this path actually is shared with your OS X machine, so the container "sees" the files from your OS X machine. 由于来宾添加了“技巧”,该路径实际上与OS X计算机共享,因此容器“看到”了OS X计算机中的文件。

However, any directory outside of the /Users/ directory is not shared between the OS X machine and the VM. 但是, /Users/目录之外的任何目录都不在OS X机器和VM之间共享。 If you try to bind-mount a path that does not exist inside the VM, docker creates an empty directory (it assumes you want to mount a directory, because it has no way to tell if it should be a directory or a file), and mounts that directory inside the container. 如果您尝试绑定安装虚拟机中不存在的路径,则docker将创建一个空目录 (假定您要安装目录,因为它无法确定它应该是目录还是文件),并将该目录装入容器中。

In your example, you try to bind mount; 在您的示例中,您尝试绑定mount;

/Applications/MAMP/htdocs/clients/codingmachine/myapp/mysql/custom-my.cnf

Inside the container at; 在容器内部;

/etc/mysql/mysql.cnf

The /Applications directory is not shared with the VM, so docker creates an empty directory named custom-my.cnf inside the VM, then tries to mount that directory at /etc/mysql/mysql.cnf inside the container. /Applications目录中没有与VM共享,因此搬运工创建一个名为空目录 custom-my.cnf的虚拟机内,然后尝试安装该目录在/etc/mysql/mysql.cnf容器内。 This fails, because you cannot mount a directory on top of a file, and Linux produces an error "not a directory". 这将失败,因为您无法在文件顶部安装目录,并且Linux会产生错误“非目录”。

To resolve your issue; 解决您的问题;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM