Browse Source

Merge pull request #21961 from yongtang/21956-docker-inspect-log-default-options

Docker inspect gave default log options even when the option is emtpy.
Brian Goff 9 years ago
parent
commit
e9bef66021
2 changed files with 14 additions and 10 deletions
  1. 0 10
      daemon/inspect.go
  2. 14 0
      integration-cli/docker_cli_daemon_test.go

+ 0 - 10
daemon/inspect.go

@@ -108,16 +108,6 @@ func (daemon *Daemon) getInspectData(container *container.Container, size bool)
 		hostConfig.Links = append(hostConfig.Links, fmt.Sprintf("%s:%s", child.Name, linkAlias))
 	}
 
-	// we need this trick to preserve empty log driver, so
-	// container will use daemon defaults even if daemon changes them
-	if hostConfig.LogConfig.Type == "" {
-		hostConfig.LogConfig.Type = daemon.defaultLogConfig.Type
-	}
-
-	if len(hostConfig.LogConfig.Config) == 0 {
-		hostConfig.LogConfig.Config = daemon.defaultLogConfig.Config
-	}
-
 	containerState := &types.ContainerState{
 		Status:     container.State.StateString(),
 		Running:    container.State.Running,

+ 14 - 0
integration-cli/docker_cli_daemon_test.go

@@ -2224,3 +2224,17 @@ func (s *DockerSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
 	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Store: consul://consuladdr:consulport/some/path"))
 	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: 192.168.56.100:0"))
 }
+
+// Test for #21956
+func (s *DockerDaemonSuite) TestDaemonLogOptions(c *check.C) {
+	err := s.d.StartWithBusybox("--log-driver=syslog", "--log-opt=syslog-address=udp://127.0.0.1:514")
+	c.Assert(err, check.IsNil)
+
+	out, err := s.d.Cmd("run", "-d", "--log-driver=json-file", "busybox", "top")
+	c.Assert(err, check.IsNil, check.Commentf(out))
+	id := strings.TrimSpace(out)
+
+	out, err = s.d.Cmd("inspect", "--format='{{.HostConfig.LogConfig}}'", id)
+	c.Assert(err, check.IsNil, check.Commentf(out))
+	c.Assert(out, checker.Contains, "{json-file map[]}")
+}