diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 347165e010..9d8df082f1 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -2560,6 +2560,7 @@ _docker_daemon() { --raw-logs --selinux-enabled --userland-proxy=false + --validate --version -v " local options_with_args=" diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 5a4ad4b6c2..af981246b9 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -2791,7 +2791,8 @@ __docker_subcommand() { "($help)--tlsverify[Use TLS and verify the remote]" \ "($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \ "($help)--userland-proxy[Use userland proxy for loopback traffic]" \ - "($help)--userland-proxy-path=[Path to the userland proxy binary]:binary:_files" && ret=0 + "($help)--userland-proxy-path=[Path to the userland proxy binary]:binary:_files" \ + "($help)--validate[Validate daemon configuration and exit]" && ret=0 case $state in (cluster-store) diff --git a/docs/reference/commandline/dockerd.md b/docs/reference/commandline/dockerd.md index e3414168e0..0b984fe56b 100644 --- a/docs/reference/commandline/dockerd.md +++ b/docs/reference/commandline/dockerd.md @@ -104,6 +104,7 @@ Options: --userland-proxy Use userland proxy for loopback traffic (default true) --userland-proxy-path string Path to the userland proxy binary --userns-remap string User/Group setting for user namespaces + --validate Validate daemon configuration and exit -v, --version Print version information and quit ``` @@ -1334,6 +1335,25 @@ For example, the daemon fails to start if you set daemon labels in the configuration file and also set daemon labels via the `--label` flag. Options that are not present in the file are ignored when the daemon starts. +The `--validate` option allows to validate a configuration file without +starting the Docker daemon. A non-zero exit code is returned for invalid +configuration files. + +```console +$ dockerd --validate --config-file=/tmp/valid-config.json +configuration OK + +$ echo $? +0 + +$ dockerd --validate --config-file /tmp/invalid-config.json +unable to configure the Docker daemon with file /tmp/invalid-config.json: the following directives don't match any configuration option: unknown-option + +$ echo $? +1 +``` + + ##### On Linux The default location of the configuration file on Linux is diff --git a/man/dockerd.8.md b/man/dockerd.8.md index 4af47c568e..01a88803af 100644 --- a/man/dockerd.8.md +++ b/man/dockerd.8.md @@ -75,6 +75,7 @@ dockerd - Enable daemon mode [**--userland-proxy**[=*true*]] [**--userland-proxy-path**[=*""*]] [**--userns-remap**[=*default*]] +[**--validate**] # DESCRIPTION **dockerd** is used for starting the Docker daemon (i.e., to command the daemon @@ -411,6 +412,9 @@ unix://[/path/to/socket] to use. daemon to lookup the user and group's subordinate ID ranges for use as the user namespace mappings for contained processes. +**--validate** + Validate daemon configuration and exit. + # STORAGE DRIVER OPTIONS Docker uses storage backends (known as "graphdrivers" in the Docker