Remote API useful tricks for Docker on Mac OS X

Remote API useful tricks for Docker on Mac OS X

Install Socat

Socat allow you to forward ports to a variety of things. For Docker forwarding a port to the docker.sock file makes a quick way to get access to the Docker remote api.
Docker also allow a way to open up that TCP port however on Mac it is temperamental and hard to use

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

Create an IP alias

Running Docker containers locally is a fairly common thing. Interconnectivity between containers works naturally. However, sometimes you may also want a container to connect back to the Docker Remote API. If you are constantly on the go changing networks you do not want to have to change that IP address every time.
A great use case for this is running Jenkins and using docker slaves

sudo ifconfig lo0 alias

Remote API

There are also some interesting endpoints you can use for information

curl http://localhost:2375
curl http://localhost:2375/containers/json
curl http://localhost:2375/images/json