Hi ,
I’ve tried to install jenkins on one ec2 instance and docker on the other ec2. While running the pipeline using the docker commands. The connection issue is been coming up. I’ve tried to install the required plugins and rerun the pipeline but same error. Could you guide me in this scenario how to connect the docker to the jenkins( configuration process ). Thanks !!
What have you configured so far? You could expose the docker daemon over the network and then protect it with an NSG.
I’ve generated the SSH keypairs in docker and have downloaded the public key in jenkins server in authorized keys as well. But still got no luck with that. It is using the unix socket. There was no daemon.json created so i’ve created one and tried to expose then the docker has stopped working. and when i tried to remove the config file then again if I try to restart docker its working fine. I dont how to expose that to jenkins server.
You can refer to this guide for setting up network access to the Docker daemon:
Configure remote access for Docker daemon | Docker Docs
However be sure to read the red text, if you are not careful you can leave your Docker host vulnerable. Also I would strongly suggest you secure the endpoint with TLS and also use an NSG to limit access.
Then once that is setup you can install the Docker Cloud plugin for Jenkins.
I’ve tried to configure as mentioned in the official docs and also did test the connection in jenkins it is working fine. But when I try to run the build then I’m popped up with this situation no matter what how many times I try to check the installations and restart the jenkins as well. The docker is up and running and status is active.
Error:
$ /var/lib/jenkins/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/Docker/bin/docker login -u sharadvanth -p ******** https://index.docker.io/v1/
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
It shouldn’t be connecting using the socket, it should be using the network connection. See the documentation for Docker Cloud:
Docker | Jenkins plugin