[英]Docker run failed for MySQL container with permission errors when using a volume - Catalina MacOS X
I am running the following command from the mac os x Catalina terminal:我正在从 mac os x Catalina 终端运行以下命令:
docker run -p 13306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD="password12" --volume /usr/local/mysql_data:/var/lib/mysql -d mysql:latest
I get the following error on the console screen:我在控制台屏幕上收到以下错误:
docker: Error response from daemon: pull access denied for run, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
docker:来自守护进程的错误响应:拒绝运行拉取访问,存储库不存在或可能需要“docker login”:拒绝:请求的资源访问被拒绝。
See 'docker run --help'.请参阅“docker run --help”。
This command runs and works if I run it without the --volume or -v option.如果我在没有 --volume 或 -v 选项的情况下运行它,该命令将运行并有效。
Also, if I run from the Docker dashboard with the volume option set I see the following error on the logs screen:此外,如果我从 Docker 仪表板运行并设置了卷选项,我会在日志屏幕上看到以下错误:
2022-04-12 19:44:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.
2022-04-12 19:44:03+00:00 [Note] [Entrypoint]: MySQL Server 8.0.28-1debian10 的入口点脚本已启动。
chown: changing ownership of '/var/lib/mysql/': Operation not permitted**chown:更改“/var/lib/mysql/”的所有权:不允许操作**
This seems to indicate a permissions issue but I did add this path to the resources->file sharing in the docker dashboard.这似乎表明存在权限问题,但我确实将此路径添加到了 docker 仪表板中的资源-> 文件共享。 I saw a few articles indicating an issue with the Catalina and Docker but did not find a fix for the issue.
我看到一些文章指出 Catalina 和 Docker 存在问题,但没有找到解决该问题的方法。
So, according to the documentation all attached volumes will be with :rw
by default, after a few tests I could see in mac it is not that way, so add :rw
to the volume and it will work因此,根据文档,默认情况下所有附加的卷都将带有
:rw
,经过几次测试后我可以在 mac 中看到它不是那样的,所以将:rw
添加到卷中它会起作用
docker run -p 13306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD="password12" --volume /usr/local/mysql_data:/var/lib/mysql:rw -d mysql:latest
Also works with named volumes:也适用于命名卷:
docker run -p 13306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD="password12" --volume mysql_data:/var/lib/mysql -d mysql:latest
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.