The docker command in the sink host runs in the docker container

  docker, question
  1. Recently, I was working on the deployment of jenkins docker, and encountered a problem. I implemented docker version in jenkins configuration, and found that the construction failed. The console reported docker not found,jenkins was running in the way of docker Mirror. After thinking about it, I should report this error, because the docker command cannot be executed in docker. If you want to use docker deployment, you should solve the problem. docker-related commands to create containers can be executed in docker. This method of using docker has its original intention. I think you should call the API of the host through the API in the container, and then solve the problem. However, I don’t know if there is a mature solution to this problem, which is not necessarily my idea. The elder who stepped on this pit, asked for sharing.

I just stepped on it, but I’m not a senior. The single mount upstairs is not enough. jenkins users need to be added to the docker group when the image is built.

ARG dockerGid=999
 RUN echo "docker:x:${dockerGid}:jenkins" >> /etc/group

I got a mirror that can run docker with jenkins users.
Direct pull can be used:

docker pull tomsun28/jenkins:1.1


docker run -d -p 8080:8080 -p 50000:50000 --name jenkins --restart=always \
 -v /opt/dockerWorkspace/jenkins_home:/var/jenkins_home \
 -v $(which docker):/usr/bin/docker \
 -v /var/run/docker.sock:/var/run/docker.sock  tomsun28/jenkins:1.1

The specific process and the Dockerfile built heretomsun28