docker configuration: daemon.json to have socket and IP in docker daemon

icordoba picture icordoba · Feb 24, 2017 · Viewed 7k times · Source

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?

Answer

Mike G. picture Mike G. · May 16, 2017

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"]
}