3

My starting point is:

so I edit /etc/init/docker.conf and update 2 occurrences of the DOCKER_OPTS variable to:

DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'

Then, a simple test to list docker images fails:

$ service docker restart
$ curl -X GET http://10.143.0.218:4243/images/json
curl: (7) Failed to connect to 10.143.0.218 port 4243: Connection refused

Docker version is:

$ sudo docker version
Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 19:06:36 2016
OS/Arch:      linux/arm

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 19:06:36 2016
 OS/Arch:      linux/arm
Community
  • 1
  • 1
tgogos
  • 23,218
  • 20
  • 96
  • 128

2 Answers2

8

The solution comes from the comments of this page: http://www.virtuallyghetto.com/2014/07/quick-tip-how-to-enable-docker-remote-api.html

[08/18/2016 at 6:00 am] Oliver Weise says: Thanks, that put me in the right direction. However since Ubuntu 16.04 with its systemd docker daemon the /etc/default/docker is no longer effective. Instead you need to create a systemd dropin file.

I placed such a file under: /etc/systemd/system/docker.service.d/remote-api.conf

With the contents:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://127.0.0.1:2376 -H unix:///var/run/docker.sock

(Yes, the double ExecStart is necessary)

After that run:

sudo systemctl daemon-reload // reloading daemon definitions
sudo systemctl restart docker
tgogos
  • 23,218
  • 20
  • 96
  • 128
  • Isn't this basically my answer? – johnharris85 Nov 15 '16 at 16:18
  • 1
    ^ No. Your answer was to go read a bunch of docs that apparently didn't clearly answer the question. :-) – Andres Dec 25 '17 at 00:07
  • This is probably the correct answer, but for me I was unable to get the API working without actually editing /lib/systems/system/docker.service directly. No matter what I put in a drop-in file, the service would pick it up but the API would only be bound to the daemon socket. The drop-in method is probably the best way to go, and perhaps the reason it wasn't a success was the method to install docker> I used: https://medium.freecodecamp.org/the-easy-way-to-set-up-docker-on-a-raspberry-pi-7d24ced073ef and have had no issues otherwise. – Thomas Carlisle Oct 20 '18 at 15:34
  • 1
    mine was located at /etc/systemd/system/multi-user.target.wants/docker.service and i only updated the tcp line. raspbian – owen gerig Nov 05 '20 at 15:20
1

Not tested this, but if it's Jessie, then it uses systemd by default as the init system iirc, and this has implications for how the daemon (dockerd) is configured and started.

So you're editing the /etc/init/docker.conf file but I don't think that's being read / used.

Take a read of this article on different startup procedures on each init system in Docker, and this for specific systemd configuration.

johnharris85
  • 17,264
  • 5
  • 48
  • 52