浏览代码

Merge pull request #37419 from thaJeztah/pass_loglevel_to_containerd

Pass log-level to containerd
Sebastiaan van Stijn 7 年之前
父节点
当前提交
42bd8e1b10

+ 2 - 0
cmd/dockerd/daemon_unix.go

@@ -48,6 +48,8 @@ func (cli *DaemonCli) getPlatformRemoteOptions() ([]libcontainerd.RemoteOption,
 	}
 	if cli.Config.Debug {
 		opts = append(opts, libcontainerd.WithLogLevel("debug"))
+	} else if cli.Config.LogLevel != "" {
+		opts = append(opts, libcontainerd.WithLogLevel(cli.Config.LogLevel))
 	}
 	if cli.Config.ContainerdAddr != "" {
 		opts = append(opts, libcontainerd.WithRemoteAddr(cli.Config.ContainerdAddr))

+ 5 - 0
libcontainerd/remote_daemon.go

@@ -221,6 +221,11 @@ func (r *remote) startContainerd() error {
 	}
 
 	args := []string{"--config", configFile}
+
+	if r.Debug.Level != "" {
+		args = append(args, "--log-level", r.Debug.Level)
+	}
+
 	cmd := exec.Command(binaryName, args...)
 	// redirect containerd logs to docker logs
 	cmd.Stdout = os.Stdout

+ 0 - 3
libcontainerd/remote_daemon_linux.go

@@ -28,9 +28,6 @@ func (r *remote) setDefaults() {
 	if r.Debug.Address == "" {
 		r.Debug.Address = filepath.Join(r.stateDir, debugSockFile)
 	}
-	if r.Debug.Level == "" {
-		r.Debug.Level = "info"
-	}
 	if r.OOMScore == 0 {
 		r.OOMScore = -999
 	}

+ 0 - 3
libcontainerd/remote_daemon_windows.go

@@ -18,9 +18,6 @@ func (r *remote) setDefaults() {
 	if r.Debug.Address == "" {
 		r.Debug.Address = debugPipeName
 	}
-	if r.Debug.Level == "" {
-		r.Debug.Level = "info"
-	}
 	if r.snapshotter == "" {
 		r.snapshotter = "naive" // TODO(mlaventure): switch to "windows" once implemented
 	}