I have installed docker on Mac and everything is running fine. I am using a Jenkins docker image and running it. While using Jenkins as a CI server and to build further images by running docker commands through it, I came to know that we have to bind mount /var/run/docker.sock while running the Jenkins images so it can access the docker daemon.
I did that and installed docker CLI inside Jenkins’s container but when running “docker ps” or any other docker command it is throwing the below error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.28/containers/json: dial unix /var/run/docker.sock: connect: permission denied
When I connect to container as a root user, it works fine. But switching to the ‘jenkins’ user throws the above error. I have already added ‘jenkins’ user to sudo list but does not help.
I found few articles suggesting to add ‘jenkins’ user to ‘docker’ group but to my surprise I do not find any docker group on Mac or inside container.
Any help is much appreciated. Thanks
No, but this works:
jenkins
) to thestaff
-group:sudo dseditgroup -o edit -a jenkins -t user staff
sudo visudo
add:%staff ALL = (ALL) ALL
I got this issue today. Here is the cause and fix:
I've started
docker for mac
asuser A
and try to run docker commands asuser B
.Fix:
Stopped
docker for mac
asuser A
and started asuser B
.