New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to set daemon and server configurations in a file. #18587
Conversation
20d7352
to
7255c49
Compare
@@ -47,6 +47,9 @@ func NewDaemonCli() *DaemonCli { | |||
daemonConfig := new(daemon.Config) | |||
daemonConfig.LogConfig.Config = make(map[string]string) | |||
daemonConfig.ClusterOpts = make(map[string]string) | |||
|
|||
daemonFlags.StringVar(&daemonConfig.ConfigurationFile, []string{"-config"}, "", "Daemon configuration file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about having a default path, and then doing the fsnotify watch even if it doesn't exist so we can catch creation of the file after the daemon starts up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense. I'll play with it to see how it feels.
Very cool! Thanks for picking this up! :-) |
@calavera I might be misreading your comment, but does the config file flags override the cmd line flags? If so, I think it should be the other way around. I believe, typically, its: process config file, env vars and then cmd line flags - where last one in that list wins. |
7255c49
to
4bf22ca
Compare
@duglin I think I agree with you. I started implementing it that way but I had some issues with duplicated flags. Definitely worth considering. |
20f3bbc
to
d7b5f20
Compare
} | ||
}() | ||
|
||
watcher.Add(configFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this can return an error due to things like inotify exhaustion.
This is really where fallback to polling should happen (if you want it to fallback).
While I like auto-reloading on changes, it seems like it could be dangerous due to partial changes. |
We may need a "configcheck" option, so that the configuration can be validated before its applied |
d7b5f20
to
ebe418c
Compare
I agree with @duglin the order of configs should be first config file, then flags (elasticsearch for instance works this way IIRC) |
Thank you all for your feedback! 💪 Given what I'm reading in these comments, and that the release freeze is close, I think this is the best plan to approach this feature for 1.10:
I'd also like to restrict the configuration elements we reload in this first version to only these:
@dhiltgen please, take a look at this, I'd like to make sure you're okay with this initial set of features. |
Yes, I think this should work. Thanks! |
Cool @calavera . Like @cpuguy83 mentioned, what's the reasoning for watching the file and reloading automatically when something changes? Some things to consider in this regard:
|
@nathanleclaire read my latest comment (before this one) |
@calavera Ah OK I didn't see. That seems reasonable -- thanks! |
ebe418c
to
6a9aaad
Compare
ping @vdemeester @MHBauer @jamtur01 for review |
## Daemon configuration file | ||
|
||
The `--config-file` option allows you to set any configuration option for the daemon | ||
in a JSON format. This file uses the flag names as keys to set documentation. By |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file uses the flag names as keys to set documentation
no idea what this means, looking for alternatives.
@calavera you need to update |
to restart the process. We use SIGHUP in Linux to reload and a global event | ||
in Windows with the key `Global\docker-daemon-config-$PID`. The options can | ||
be modified in the configuration file but still will check for conflicts with | ||
the provided flags. The daemon fails to reconfigure itself if there are conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conflicts but
conflicts, but
5993f86
to
961de3c
Compare
@vdemeester done, thanks! |
@calavera another question about the output when there is conflicts. With 2 conflicts, I ended up with that : 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: debug
: (from flag: true, from file: true), labels: (from flag: [bar=foo], from file: [foo=bar]) I think it would be a clearer if we put one conflict by line (carriage return, etc..), something like : 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:
- debug: (from flag: true, from file: true)
- labels: (from flag: [bar=foo], from file: [foo=bar]) wdyt ? 😝 👼 |
that option was discarded after @cpuguy83's comment |
### Configuration reloading | ||
|
||
Some options can be reconfigured when the daemon is running without requiring | ||
to restart the process. We use SIGHUP in Linux to reload, and a global event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe SIGHUP
😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or: "We use the SIGHUP
signal"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed with "We use the SIGHUP
signal"`
small nit but docs LGTM 🐮 |
Read configuration after flags making this the priority: 1- Apply configuration from file. 2- Apply configuration from flags. Reload configuration when a signal is received, USR2 in Linux: - Reload router if the debug configuration changes. - Reload daemon labels. - Reload cluster discovery. Signed-off-by: David Calavera <david.calavera@gmail.com>
961de3c
to
677a6b3
Compare
docs LGTM \o/ |
https://jenkins.dockerproject.org/job/Docker-PRs-experimental/13695/console hang and timed out... |
It's greeeeeeen! |
Allow to set daemon and server configurations in a file.
This looks cool, but its potential is far from delivered. It's still totally undocumented at https://docs.docker.com/engine/admin/configuring/ and a user has no idea of what settings are supported and what is the syntax. I will say that config file is the way to go by default for packaged docker: it's way easier than overriding the systemd unit. Other than SIGHUP, I would also consider a |
@soulrebel agreed that the documentation for configuring the daemon needs to be touched up (in general as well, because the docs is now spread over several locations) For using this file by default, see this issue #20151, which I opened to discuss that. |
Still a work in progress but I thought it could be a good idea to show this now that mostly works.
Read configuration after flags making this the priority:
1- Apply configuration from file.
2- Apply configuration from flags.
Reload configuration when it a signal is received, HUP in Linux:
Closes #17559
Signed-off-by: David Calavera david.calavera@gmail.com