Docker Community Forums

Share and learn in the Docker community.

Unable to connect to Docker Daemon from Jenkins Docker Plugin on MacOS


(Yogesh Arora) #1

Hi there,

Just to tell you the background, I want to run Jenkins agents as Docker container. Jenkins Master is not running in a container. Therefore, I’ve installed Docker Plugin in my Jenkins. However, I’m unable to connect to Docker Daemon from Jenkins Docker Plugin. Getting the below error during Test Connection:

  1. When supply Docker Host URL as “unix://127.0.0.1:2375”, then
    connect(…) failed: Permission denied: /var/run/docker.sock

  2. When supply Docker Host URL as “tcp://127.0.0.1:2375” then
    Connection refused: /127.0.0.1:2375

Environment:
MacOS: 10.13.4
Jenkins 2.89.3
Docker Plugin: 1.1.4

Any help in this regard is very appreciated.

Thanks,
Yogesh


(Archimedes Trajano) #2

The docker.sock file is owned by root and does not allow write permissions by other. You have to make it such that jenkins can read/write to that socket file when mounted. (That’s a bad idea though security wise)

To enable the docker host URL you need the host’s IP rather than 127.0.0.1 which is the container’s localhost.


(Yogesh Arora) #3

Hi,

Thanks a lot for your quick response.

In case of TCP, I had tried to use container’s localhost as well (i.e. tcp://172.17.0.1:2375). However, getting connection time-out error.

connection timed out: /172.17.0.1:2375

Is there any other setting on the daemon that could be missing ?

In case of unix://, I’m struggling to understand the docker group and which user needs to be added to docker group.

Can you please throw some light on these two issues? Many thanks in advance !

Thanks,
Yogesh


(Yogesh Arora) #4

Hi There,

Looks like, I hit this known issue due to which I’m unable to connect to Docker host.

Thanks,
Yogesh


(Archimedes Trajano) #5

That’s still an internal IP address, do you have an IP address that other computers in your network (not the same machine) can access services you expose? And if so see if you nc -z -v IPADDRESS 2376


(Yogesh Arora) #6

I’m running both Jenkins and Docker on the same mac laptop.


(Yogesh Arora) #7

Hi,

I’m able to successfully run this with socat.
sudo socat tcp-listen:2375,reuseaddr,fork,bind=127.0.0.1 unix-client:/var/run/docker.sock,su=root

Is there a better to run this on Mac ? If not, I would have to live with this solution for the time being.

Thanks,
Yogesh