diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index 5ade4f34ff..a93e93f5d7 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -589,13 +589,13 @@ func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) return nil, err } - if cli.Config.Debug { + if cli.Debug { opts = append(opts, supervisor.WithLogLevel("debug")) - } else if cli.Config.LogLevel != "" { - opts = append(opts, supervisor.WithLogLevel(cli.Config.LogLevel)) + } else { + opts = append(opts, supervisor.WithLogLevel(cli.LogLevel)) } - if !cli.Config.CriContainerd { + if !cli.CriContainerd { // CRI support in the managed daemon is currently opt-in. // // It's disabled by default, originally because it was listening on diff --git a/libcontainerd/supervisor/remote_daemon.go b/libcontainerd/supervisor/remote_daemon.go index 83f0d6de7c..48818a86c6 100644 --- a/libcontainerd/supervisor/remote_daemon.go +++ b/libcontainerd/supervisor/remote_daemon.go @@ -48,6 +48,10 @@ type remote struct { // oomScore adjusts the OOM score for the containerd process. oomScore int + + // logLevel overrides the containerd logging-level through the --log-level + // command-line option. + logLevel string } // Daemon represents a running containerd daemon @@ -180,8 +184,8 @@ func (r *remote) startContainerd() error { args := []string{"--config", configFile} - if r.Debug.Level != "" { - args = append(args, "--log-level", r.Debug.Level) + if r.logLevel != "" { + args = append(args, "--log-level", r.logLevel) } cmd := exec.Command(binaryName, args...) diff --git a/libcontainerd/supervisor/remote_daemon_options.go b/libcontainerd/supervisor/remote_daemon_options.go index 58350be05b..49ca83cf4c 100644 --- a/libcontainerd/supervisor/remote_daemon_options.go +++ b/libcontainerd/supervisor/remote_daemon_options.go @@ -1,10 +1,14 @@ package supervisor // import "github.com/docker/docker/libcontainerd/supervisor" -// WithLogLevel defines which log level to starts containerd with. -// This only makes sense if WithStartDaemon() was set to true. +// WithLogLevel defines which log level to start containerd with. func WithLogLevel(lvl string) DaemonOpt { return func(r *remote) error { - r.Debug.Level = lvl + if lvl == "info" { + // both dockerd and containerd default log-level is "info", + // so don't pass the default. + lvl = "" + } + r.logLevel = lvl return nil } }