0

I am trying to setup docker daemon on Centos 7.

The goal is to pass parameters to the overriding script in systemd and keep everything in daemon.json that is much more readable and cleaner

Default script /etc/systemd/system/docker.service.d/10-machine.conf is:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver overlay2 --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic --insecure-registry mtm-registry:5000
Environment=

/etc/systemd/system/docker.service.d/override.conf still has the --label provider=generic that is the last parameter to move in daemon.json:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --label provider=generic

In /etc/docker/daemon.json i have already setup these parameters:

{
"storage-driver": "overlay2",
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tls": true,
"tlsverify": true,
"tlscacert": "/etc/docker/ca.pem",
"tlscert": "/etc/docker/server.pem",
"tlskey": "/etc/docker/server-key.pem",
"insecure-registries": ["my-registry:5000"]
}

I am not an expert about JSON format, so I stuck in passing "labels":.

I have tried "labels": ["provider=generic"] it doesn't work, dockerd fail to start

Any suggestion in order to pass it in the right way?

SOLUTION:

I have no idea why, but after I passed the value with a space before provider=generic,

(like this: [" provider=generic"]), daemon starts correctly:

{
"storage-driver": "overlay2",
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tls": true,
"tlsverify": true,
"tlscacert": "/etc/docker/ca.pem",
"tlscert": "/etc/docker/server.pem",
"tlskey": "/etc/docker/server-key.pem",
"insecure-registries": ["mtm-registry:5000"],
"labels": [" provider=generic"] 
}

1 Answer 1

0

Should just be:

{
"storage-driver": "overlay2",
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tls": true,
"tlsverify": true,
"tlscacert": "/etc/docker/ca.pem",
"tlscert": "/etc/docker/server.pem",
"tlskey": "/etc/docker/server-key.pem",
"insecure-registries": ["my-registry:5000"],
"labels": ["provider=generic"]
}

Perhaps you missed the comma between the keys (see the line before)?


Note, there should be no need to include a space before this field. There appears to be a typo or conflict somewhere. Perhaps a RedHat specific fork change to the daemon since the following works fine on Debian:

# # my daemon.json file does not have a leading space
# jq .labels </etc/docker/daemon.json
[
  "foo=bar",
  "provider=generic"
]

# # note you only need a reload here, I'm trying to reproduce the error
# systemctl restart docker

# docker system info --format '{{json .Labels}}' | jq .
[
  "foo=bar",
  "provider=generic"
]
7
  • It doesn't work. If i put "labels": ["provider=generic"] (in the end as you shown me) i get this from logs: unable to configure the Docker daemon with file /etc/docker/daemon.json: configuration validation from file failed (bad attribute format: provider-generic) Feb 6, 2019 at 15:38
  • @fromthestone do you have a = or - there?
    – BMitch
    Feb 6, 2019 at 15:56
  • I have "=" in command line parameters, not "-", but the logs show "-" Feb 6, 2019 at 15:57
  • @fromthestone command line parameters or daemon.json file?
    – BMitch
    Feb 6, 2019 at 15:59
  • both daemon.json and command line parameters have "=", btw I found a solution and i have edited my question with that :-) Feb 6, 2019 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .