I’m running Jenkins for MacOS (using Homebrew) and Docker Desktop on Mac.
When I try to build docker image for Python app from Jenkins pipeline, the following error is reported:
+ docker build -t <docker image name>:41 .
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Jenkinsfile snippet:
pipeline {
agent none
stages {
...
stage("Build Docker Image") {
agent {
docker { image 'docker:24.0.5' }
}
environment {
HOME = "${env.WORKSPACE}"
}
steps {
script {
dockerImage = docker.build("<docker image name>:${env.BUILD_ID}")
}
}
}
...
}
}
In previous stages, docker containers are successfully used.
I found similar case here Jenkins: Can't connect to Docker daemon - Stack Overflow for CentOS. I assume that I need to add my user to docker group (even if I can already run docker
commands without sudo
) but when I run dscl . list /groups
command (the command which outputs all groups on Mac) I cannot find group named docker. I have also tried to run the following in Jenkins pipeline:
+ whoami
whoami: unknown uid 501
Then I ran id
command from my terminal to compare the uid and this is the uid of my user which I’m currently using and managing Jenkins.
Thanks in advance for any help.