Issue
I'm using Jenkins on Docker on my local Mac Machine. And I'm running another Docker on ubuntu VirtualBox. So now, there are 2 docker machines. one is on my mac machine and one is on my Ubuntu VirtualBox machine. I'm running Jenkins on Mac Docker. Now in the Jenkins pipeline, I want to build an image on my ubuntu machine. I've configured Jenkins docker cloud and in the docker host URL, it is connected to the ubuntu docker-machine. But while building a new image, I'm getting the error. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I've tried even adding ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
at /lib/systemd/system/docker.service
Can someone please help me out? help is appreciated.
Solution
I've configured it by defining the slave label in my Jenkins Pipeline. Jenkins agents run on a variety of different environments such as physical machines, virtual machines, Kubernetes clusters, and Docker images. In your Jenkins Pipeline or In your JenkinsFile, you've to set the agent accordingly to what you're using either using Docker image or any virtual machine. Also Thank you so much @Vlad, all the things you told me, were really helpful.
Answered By - Johnny Bravo