Reputation: 2626
I am running Jenkins inside a docker container.
I use the following command to start the container -
docker run -p 8080:8080 -p 50000:50000 -v "${PWD}:/var/jenkins_home" -v /var/run/docker.sock:/var/run/docker.sock aemdesign/jenkins
Notice -v /var/run/docker.sock:/var/run/docker.sock
- I have done this so that I can access the docker daemon from within Jenkins as per this article.
I cd
into the jenkins container using docker exec -it <mycontainer> bash
I then run docker ps -a
but I still get docker command not found error.
I did some more research online and found out about the docker plugin for Jenkins, and configured it to connect to the docker daemon. I get the following error
Am I missing something? How do I solve this issue? Please note that I am doing this locally on a MAC machine.
Upvotes: 2
Views: 217
Reputation: 31584
-v /var/run/docker.sock:/var/run/docker.sock
, this just means your container has ability to access docker daemon
on the host, not mean your container will have the docker client
.
You could use -v $(which docker):/usr/bin/docker
to add docker client
to your container, then you will find the command.
docker run -u root -p 8080:8080 -p 50000:50000 -v $(which docker):/usr/bin/docker -v "${PWD}:/var/jenkins_home" -v /var/run/docker.sock:/var/run/docker.sock aemdesign/jenkins
Another way if you want reserve jenkins user.
docker run -u jenkins:$(cut -d: -f3 < <(getent group docker)) -p 8080:8080 -p 50000:50000 -v $(which docker):/usr/bin/docker -v "${PWD}:/var/jenkins_home" -v /var/run/docker.sock:/var/run/docker.sock aemdesign/jenkins
Upvotes: 1