Access Docker daemon Remote api on Docker for Mac

2019-02-07 06:40发布

I'm runner Docker for OSX, and having trouble getting the Docker remote API to work.

My situation is this:

No I want to use the Jenkins docker-build-step plugin to build a docker image, but I want it to use the docker daemon on the host machine, so in Jenkins settings, DOCKER_URL should be something like :2375. (Reason for this is I don't want to install docker on the jenkins container if I already have it on my host machine).

Is there a way to to this or is de Docker for Mac currently not supporting this? I tried fiddling with export DOCKER_OPTS or DOCKER_HOST options but still get a Connection refused on calling http://localhost:2375/images/json for example.

Basicly the question is more about enabling the Docker for OSX remote api, with use case calling it from a Jenkins docker container.

标签: macos docker
1条回答
forever°为你锁心
2楼-- · 2019-02-07 07:08

You could consider using socat. It solved my problem, which seem to be similar.

socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock &

This allows you to access your macOS host Docker API from a Docker container using: tcp://[host IP address]:2375

On macOS socat can be installed like this:

brew install socat

See here for a long discussion on this topic: Plugin: Docker fails to connect via unix:// on Mac OS X

查看更多
登录 后发表回答