I am trying to run Jenkins pipeline job in my macbook. I also have docker instance running locally. Initially I got the "docker command not found" error while running the Jenkins Job. I fixed the error by adding a symlink "ln -f -s /Applications/Docker.app/Contents/Resources/bin/* /usr/local/bin"
I also applied these two changes so that jenkins user has the access to the docker directory
- chmod -R 777 /Users/myUserName/Library/Containers/com.docker.docker/
- chmod -R 777 /Users/myUserName/Library/Containers/com.docker.helper/
I am getting below errors:
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.27/containers/openjdk:8/json: dial unix /var/run/docker.sock: connect: permission denied [Pipeline] sh [test] Running shell script + docker pull openjdk:8 Warning: failed to get default registry endpoint from daemon (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.27/info: dial unix /var/run/docker.sock: connect: permission denied). Using system default: https://index.docker.io/v1/ Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.27/images/create?fromImage=openjdk&tag=8: dial unix /var/run/docker.sock: connect: permission denied [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE
There are any ways to solve this issue, I faced it last week, I solved but with
docker-compose
this setup is replicable todocker
, you can create a shared volume that points from the location ofdocker.sock
in your host/var/run/docker.sock
to location ofdocker.sock
in your container/var/run/docker.sock
. Something like this:To works well you have to give permissons of user to the
socket
sudo chown $USER:$USER /var/run/docker.sock
and to the group ofdocker
, as Innocent Anigbo mentioned.You can try this and worked for me:
This is a docker permission issue. Add the jenkins user to docker group as follow:
usermod -aG docker ${USER}