尝试在unix:///var/run/docker.sock连接到Docker守护程序套接字时获得权限被拒绝:

问题描述 投票:0回答:1

使用案例:

Base Instance有一个Ubuntu 16.04安装Docker,它可以查找,我可以查看docker镜像。

部署了一个Jenkins Docker容器实例。

docker run -p 8080:8080 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  --name jenkins \
  jenkins/jenkins:lts

这个Jenkins实例将主机的Docker套接字安装在容器中。正如文章中提到的那样。

https://getintodevops.com/blog/the-simple-way-to-run-docker-in-docker-for-ci

现在在Jenkins容器上安装了docker二进制文件。

apt-get update && \
apt-get -y install apt-transport-https \
 ca-certificates \
 curl \
 gnupg2 \
 software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
   $(lsb_release -cs) \
   stable" && \
apt-get update && \
apt-get -y install docker-c

从Jenkins容器中运行Docker ps并列出可用的容器。

但是当从Jenkins触发一个作业时,它失败了以下错误+ docker run hello-world docker:在尝试连接到unix的Docker守护进程套接字时获得权限被拒绝:///var/run/docker.sock:post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create:拨打unix /var/run/docker.sock:connect:权限被拒绝。

我尝试了将用户添加到组中的解决方案,但它仍然失败

https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/

任何帮助是极大的赞赏。

谢谢

docker jenkins docker-compose docker-machine
1个回答
-2
投票

我得到了这个工作。

将用户添加到组中停止并重新启动容器

© www.soinside.com 2019 - 2024. All rights reserved.