moby: Cannot load hosts in configuration json file when starting docker daemon
Output of docker version
:
root@10-11-1-156:~# docker version
Client:
Version: 1.11.0
API version: 1.23
Go version: go1.5.4
Git commit: 4dc5990
Built: Wed Apr 13 18:34:23 2016
OS/Arch: linux/amd64
Server:
Version: 1.11.0
API version: 1.23
Go version: go1.5.4
Git commit: 4dc5990
Built: Wed Apr 13 18:34:23 2016
OS/Arch: linux/amd64
Output of docker info
:
root@10-11-1-156:~# docker info
Containers: 7
Running: 0
Paused: 0
Stopped: 7
Images: 207
Server Version: 1.11.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 234
Dirperm1 Supported: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 3.13.0-83-generic
Operating System: Ubuntu 14.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.955 GiB
Name: 10-11-1-156
ID: NDA5:5CVE:Y7Y4:MQJZ:IQVN:ISZ4:5V2Q:JUMU:MGPR:BWGF:LKSR:OW5E
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Additional environment details (AWS, VirtualBox, physical, etc.):
two config file, one as flag, one for config loading
root@10-11-1-156:~# cat /etc/default/docker
DOCKER_OPTS="-H unix:///var/run/docker.sock"
root@10-11-1-156:~# cat /etc/docker/daemon.json
{"hosts":["tcp://127.0.0.1:2376"]}
when execute service docker restart
:
root@10-11-1-156:~# service docker restart
docker stop/waiting
start: Job failed to start
check docker daemon’s log:
Waiting for /var/run/docker.sock
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:///var/run/docker.sock], from file: [tcp://127.0.0.1:2376])
And I was following (https://docs.docker.com/engine/reference/commandline/daemon/#daemon-configuration-file) to add hosts
in /etc/docker/daemon.json. While fails to start docker daemon.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 31 (7 by maintainers)
Links to this issue
Commits related to this issue
- Remove /etc/docker/daemon.json or docker won't start. https://github.com/docker/docker/issues/22339 Permissions for log directory. CUR_DIR in start_server.sh is not used. — committed to pyotr777/kportal by pyotr777 8 years ago
- Remove /etc/docker/daemon.json or docker won't start. https://github.com/docker/docker/issues/22339 Permissions for log directory. CUR_DIR in start_server.sh is not used. — committed to pyotr777/kportal by pyotr777 8 years ago
This is a problem if you are using the default systemd unit file, which is hardcoded to start dockerd with -H fd://.
quick workaround (Debian 8)): create /etc/systemd/system/docker.service.d/docker.conf
then systemctl daemon-reload
This is definitely a bug in the systemd configuration. I have
DOCKER_OPTS=""
but systemd on Ubuntu 16.04 starts the docker daemon with-H fd://
. I want to configure docker with TLS over the network.Please re-open this critical bug I consider this a blocking and breaking bug.
Considering I’m trying to use
daemon.json
because/etc/default/docker
states:I recommend either fixing this bug or removing the message
Use of this file for configuring your Docker daemon is discouraged.
from/etc/default/docker
to avoid confusion.This is expected; you cannot specify options both as a flag and in the configuration file (daemon.json). If you change your DOCKER_OPTS to
DOCKER_OPTS=""
and restart, then it should work. We explicitly don’t “merge” these configurations.I’ll close this issue, as I don’t think there’s a bug here, but feel free to comment 👍
This just hit me also.
Considering the default config breaks with a
daemon.json
containinghosts
- wherehosts
is a supported config option (and a very common one I would think?) should we not consider this a bug still!?//cc @thaJeztah
we use daemon.json to avoid to discriminate what file to change based on the system (upstart/systemV, etc.) But if we have to manually empty the DOCKER_OPTS, it has no sense. so dameon should have the priority
Same, I still override it. @thaJeztah is it worth reconsidering this a bug? It still affects me but I gave up trying to change your mind until people started reporting it again.
Looks like it was documented here: https://docs.docker.com/engine/admin/#troubleshoot-conflicts-between-the-daemonjson-and-startup-scripts
I’d still like to see a modification of the packaging or Docker itself so that people don’t have to work around this. Anyone using TLS over API but also the socket will need to specify their hosts, and people upgrading from another version where they used a host config in daemon.json will have Docker break until they end up finding this issue or the new doc via their favorite search engine.
Maybe docker engine should prefer settings in daemon.json over those supplied by the flag, or vice versa.
@thaJeztah, any response to @duckie? The use of
-H
is clearly visible in docker-ce’s systemd file, and was introduced in the last version where it wasn’t used before. This broke several working configurations.Thanks @asbjornenge, real time saver. This really should be considered as a bug. According to the doc:
But when I turned to the reference, there isn’t solution for this problem.
@thaJeztah thanks for the explanation.
However,
-H
is definitely used by the systemd unit file provided in the officialdocker-ce
package, at least for the RHEL family. Therefore, it should be considered a packaging bug.-H
should not be used in the unit file so that it stays as generic as possible, and the default-H
value should be provided in the defaultdaemon.json
file instead.Unless there is a rationale to force the host value ? I cant see any valid reason.
When you use a systemd drop-in (“override”) file, you are specifying options to override, or add to the main systemd unit file.
However, a systemd unit file is allowed to have multiple
ExecStart
instructions (see the systemd man page. If you specifyExecStart
in your “override” file, it is added to the existing list ofExecStart
instructions in the main systemd unit file (and thoseExecStart
commands will be joined together).To override / replace the
ExecStart
in the main systemd unit file, it is therefore needed to first reset theExecStart
, and then define the newExecStart
to replace it. So;Example content of your override file (e.g.
/etc/systemd/system/docker.service.d/my-override.conf
);Never edit the original systemd unit file, because doing so will mark it as “edited by user”, which means that if you upgrade Docker to a newer version (install a newer version of the rpm / deb package), and that version has an updated systemd unit-file, the file won’t be updated automatically with the new version.