且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

/var/run/docker.sock:在Python CGI脚本中运行docker时拒绝权限

更新时间:2023-01-15 22:44:04

默认安装上的权限被拒绝表示您尝试从root用户以外的用户或不在docker组中的用户访问套接字。您应该能够运行:

Permission denied on a default install indicates you are trying to access the socket from a user other than root or that is not in the docker group. You should be able to run:

sudo usermod -a -G docker $username

您想要的$ username上将它们添加到组中。您需要注销然后重新登录才能生效(在现有shell中使用 newgrp docker ,或者如果这是一个外部服务,如您的外部访问docker,则重新启动守护程序。 cgi脚本)。

on your desired $username to add them to the group. You'll need to logout and back in for this to take effect (use newgrp docker in an existing shell, or restart the daemon if this is an external service accessing docker like your cgi scripts).

请注意,这样做可以有效地使该用户在您的主机上具有完全的root访问权限,因此请谨慎操作。

Note that doing this effectively gives that user full root access on your host, so do this with care.