An error is reported when the docker command is executed in Jenkins

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

When Jenkins is configured to automatically build dockerfiles from gitlab and upload them to harbor, the above problems are encountered. When Jenkins executes the docker command, the above errors will be reported. After consulting relevant data, it is found that the solutions are as follows:
I Modify docker service configuration
systemctl stop docker
sudo gpasswd - a Jenkins docker # add Jenkins users to the docker group
VIM/usr/lib/SYSTEMd/system/docker. Service

#ExecStart=/usr/bin/dockerd-current \
#          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
#          --default-runtime=docker-runc \
#          --exec-opt native.cgroupdriver=systemd \
#          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
#          $OPTIONS \
#          $ADD_REGISTRY \
#          $BLOCK_REGISTRY \
#         $REGISTRIES
ExecStart=/usr/bin/docker daemon -H unix:// -H tcp://
#Replace the above commented configuration file with the newly added file below.

systemctl daemon reload
systemctl restart docker
2. Restart the Jenkins service, build the current project, and check whether the relevant docker commands can be executed
systemctl restart Jenkins
If you encounter the problem that the filtering Jenkins process shows that the current service has been closed, but Jenkins still cannot be started, you can execute the java - jar Jenkins. War command to see the detailed error messages. What’s more wonderful is that I have closed the Jenkins process, the filtering service and port have been closed, but the address occupied error will still be reported when starting the Jenkins service, At this point, re execute the systemctl stop Jenkins command, and then start the Jenkins service to see if it can be solved


Similar Posts: