Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 748
icordoba Avatar asked Feb 24 '17 09:02

icordoba


People also ask

How do I change Docker daemon configuration?

To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon.json on Linux systems, or C:\ProgramData\docker\config\daemon.json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced. You can also start the Docker daemon manually and configure it using flags.

Where is Docker daemon JSON?

The preferred method for configuring the Docker Engine on Windows is using a configuration file. The configuration file can be found at 'C:\ProgramData\Docker\config\daemon. json'.

What is Docker daemon socket?

sock is basically the Unix socket the Docker daemon listens on by default. It is also a tool used to communicate with the Docker daemon from within a container. Sometimes, containers need to bind mount the /var/run/docker. sock file. Communication with container from docker daemon.


1 Answers

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"]
}
like image 197
Mike G. Avatar answered Sep 28 '22 18:09

Mike G.