Jenkins and Docker client
- Clone the repository in the host machine
- Build the image:
docker build -t jenkins-docker .- Start the container:
docker run -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --name jenkins -d jenkins-docker- Enter the container to verify that docker is accessible:
docker exec -it jenkins bash- Test
docker ps -a See the troubleshooting section If you get the following error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:The Dockerfile is adding a docker GID:
groupadd -g 999 docker && \Run the following command to figure out the GID on the host machine:
cat /etc/group | grep docker
# output
docker:x:998:change the Dockerfile to use 998 instead of 999 and rebuild the image in the host machine.
As a last resort
Run the following command to allow the whole system to write to the docker socket (which is not recommended for production setups, but just to get started).
chmod o+rw /var/run/docker.sock Rerun the image.