Connect to RemoteAPI from within container

Hi, Does anyone know how to configure a container so that it can access the remote api on the host?

I can access the api from the host no problem. If I try to curl from within the container:

curl 172.17.42.1:2375/images/json?all=0

I get the error “Couldn’t connect to host”.

I can ping the ip from within the container and I launched the docker demon with:

docker -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 -d

Is there an extra permission or configuration that I missed?

Cheers.

Untested because I’m on mobile, but I believe you need to bind mount the docker socket when you run the container.

docker run -v /var/run/docker.sock:/var/run/docker.sock -it /bin/bash

Scott

You need to bind to the public IP, or as suggested above, “share” the unix socket as a volume and then connect to that.
However you won’t be able to use curl, I think, to connect to the unix socket.

If you use a public IP a local firewall on the docker server can be used to restrict access from the outisde, or specific container IPs.