Docker 权限被拒绝 运行 docker 作为 nginx
Docker Permission Denied run docker as nginx
<?php
error_reporting(-1);
ini_set('display_errors', '1');
$code = addslashes($_GET['code']);
echo shell_exec("/usr/bin/docker exec d6ebc1b02e76 perl -e \"$code\" 2>&1");
从 nginx 执行此 PHP 脚本时,我得到以下信息:
time="2015-07-30T23:46:03-04:00" level=fatal
msg="Post http:///var/run/docker.sock/v1.18/containers/d6ebc1b02e76/exec: dial
unix /var/run/docker.sock: permission denied. Are you trying to connect to a
TLS-enabled daemon without TLS?"
除了让 nginx sudo 访问 docker 还有其他解决方案吗?
摘自
的文档
https://docs.docker.com/installation/ubuntulinux/#optional-configurations-for-docker-on-ubuntu
"To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group."
你可以试试
如果你需要 运行 docker 作为非 root 用户执行命令:像这样尝试
一种。创建用户'docker'->#adduserdocker,passwddocker
b.添加群组 docker -> groupadd docker
C。 sudo usermod -aG docker docker
注意将条目添加到 /etc/sudoers
%sudo 全部=(全部:全部)全部 | %sudo 所有=(所有:所有)所有
<?php
error_reporting(-1);
ini_set('display_errors', '1');
$code = addslashes($_GET['code']);
echo shell_exec("/usr/bin/docker exec d6ebc1b02e76 perl -e \"$code\" 2>&1");
从 nginx 执行此 PHP 脚本时,我得到以下信息:
time="2015-07-30T23:46:03-04:00" level=fatal
msg="Post http:///var/run/docker.sock/v1.18/containers/d6ebc1b02e76/exec: dial
unix /var/run/docker.sock: permission denied. Are you trying to connect to a
TLS-enabled daemon without TLS?"
除了让 nginx sudo 访问 docker 还有其他解决方案吗?
摘自
的文档https://docs.docker.com/installation/ubuntulinux/#optional-configurations-for-docker-on-ubuntu
"To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group."
你可以试试
如果你需要 运行 docker 作为非 root 用户执行命令:像这样尝试 一种。创建用户'docker'->#adduserdocker,passwddocker b.添加群组 docker -> groupadd docker C。 sudo usermod -aG docker docker
注意将条目添加到 /etc/sudoers %sudo 全部=(全部:全部)全部 | %sudo 所有=(所有:所有)所有