docker: Error response from daemon: error while creating mount source path '/usr/local/bin/docker': chown /usr/local/bin/docker: no such file or directory.
I use Jenkins on a docker image, and I use it to build docker images, I have installed docker on the Jenkins image as well, I did it so I can control the docker version. I still need to run it in privileged mode though. I know there is a way to access the host Docker, but I haven’t tried too hard to get it to go.
There is a confusion where the docker command can run.
It can run inside Jenkins host. Just check if docker is installed along with the Jenkins.
It can run inside container which is created by Jenkins. In this case an image should already contain a docker installation if you plan to use a docker inside of a container.
@jpetazzo is it possible to implement the side car pattern from a jenkins pipeline script where jenkins itself is installed on a container i.e. can the agent being instantiated from the pipeline script run from the host machine? Per your post, I would rather stay away from running docker inside a docker container.
Are there any example of installing the Docker CLI using your base image’s packaging system, or using the Docker API?
Edit: Never mind, that’s literally what you explain in the article thanks!
You should not mount the binary as mentioned in the answer above but instead install the docker client in your container.
Reason is that the binary is linking against a shared library which you would need to mount as well into the container. But doing that would result in other issues (eg. wrong system dependencies).
Former versions of this post advised to bind-mount the docker binary from the host to the container. This is not reliable anymore, because the Docker Engine is no longer distributed as (almost) static libraries.
Basically the solution is to build a docker container which will build upon jenkins and install docker into it, at the end its basically jenkins with the docker client (not server) installed, and when running it you connect it to the host docker.sock as was mentioned above as well