Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Docker daemon Remote api on Docker for Mac

Tags:

docker

macos

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

My situation is this:

  • Docker daemon running natively on OSX (https://www.docker.com/products/docker#/mac, so not the boot2docker variant)
  • Jenkins running as docker image

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.

like image 419
Mark Pardijs Avatar asked Sep 09 '16 12:09

Mark Pardijs


1 Answers

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

like image 126
DockerEverything Avatar answered Oct 20 '22 17:10

DockerEverything