5

After updating my OpenSUSE docker host to last version, 1.12.6, I can't have docker daemon both listening do socket and IP.

If I include

"hosts": ["tcp://192.168.1.1:2376"]

in my daemon.json, it binds correctly to that IP and I can connect to docker from my intranet, but it won't open local socket so I can execute docker commands locally. If I remove that hosts entry, local docker commands work (default configuration) but obviously I can't access the host from the Intranet.

Adding fd:// to hosts JSON array won't work. I get an error message when restarting docker service stating that there are no sockets available.

My question is: What is the configuration to include in daemon.json "hosts" entry to add not only tcp hosts but also socket?

icordoba
  • 1,834
  • 2
  • 33
  • 60
  • the issue is that "hosts" option overrides docker default value rather than appends. So you have so specifiy both unix socket (to connect like docker ps -a) and tcp socket. – Mike G. May 16 '17 at 12:37

1 Answers1

6

by default you have to edit

/etc/docker/daemon.json

file content:

{
  "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"]
}

You may also add other sockets if you need / want.

If you want to use some web client you might need to add CORS:

{
  "api-enable-cors": true,
  "api-cors-header": "*",
  "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2375"]
}
Mike G.
  • 3,860
  • 3
  • 17
  • 18
  • 1
    `unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [unix://], from file: [unix:///var/run/docker.sock tcp://0.0.0.0:2375])` but `/etc/systemd/system/docker.service.d/docker.conf` with ``` [Service] ExecStart= ExecStart=/usr/bin/dockerd ``` helps (sorry for bad formatting) – MaximKostrikin Nov 12 '18 at 05:29
  • @MaximKostrikin remove "-H unix://" flag from "/etc/systemd/system/docker.service.d/docker.conf" file – Daniel Andrzejewski Feb 10 '23 at 11:41