less than 1 minute read

I was recently tasked with an issue to allow an application, deployed using docker-compose, to launch containers and I did not want to go the docker-in-docker route.

I then figured that using the Docker Remote API to provide this functionality would be sufficient, however, I had difficulties on how to enable the tcp Socket on distributions running systemd like Ubuntu 16.04.2, as adding

DOCKER_OPTS="-H tcp:// -H unix:///var/run/docker.sock"

to /etc/default/docker does not work.

This is what I pieced together from the Internet:

Edit the file /lib/systemd/system/docker.service:

  $ sudo vi /lib/systemd/system/docker.service

Append the following to the ExecStart=/usr/bin/dockerd -H fd:// line:

-H tcp:// -H unix:///var/run/docker.sock

Reload systemd:

$ sudo systemctl daemon-reload

Restart docker:

$ sudo systemctl restart docker

Test with curl:

$ curl -X GET

The above should respond with OK.

Hope someone out there finds this helpful.

NOTE: This provides un-encrypted and un-authenticated direct access to the daemon.

Leave a comment