I've got Jenkins official image deployed into Docker container on my Mac and I need to use docker commands here.
The question: How to correctly embed Docker executables to Docker's image (i.e.Jenkins image) in order Docker to use docker commands?
Here what I did:
- Runned Jenkins container with additional parameter of
-v /var/run/docker.sock:/var/run/docker.sock
. Gettingpermission denied
when try to accessdocker build
. - Then I assigned sudo privileges inside container to Jenkins user
usermod -aG sudo jenkins
to Jenkins user and rebooted, the error is still here.
root@4328a7e643ea:/ groups jenkins
jenkins : jenkins sudo
- Doing
chmod 777 /var/run/docker.sock
on the host computer and reboot then hasn't helped too.
Additional info:
The parameters I used to create Jenkins container in Docker:
docker run --name jenkins --restart=on-failure --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--publish 9000:8080 --publish 60000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
--volume /usr/local/bin/docker:/usr/bin/docker \
--volume /var/run/docker.sock:/var/run/docker.sock \
jenkins/jenkins:jdk17
After a whole day is wasted on reading & trying, I've finally gave up. Please, help me understand how to overcome this issue.