Skip to content

Commit

Permalink
Merge pull request #21961 from yongtang/21956-docker-inspect-log-defa…
Browse files Browse the repository at this point in the history
…ult-options

Docker inspect gave default log options even when the option is emtpy.
  • Loading branch information
cpuguy83 committed May 6, 2016
2 parents 68ba274 + 4b5404f commit e9bef66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
10 changes: 0 additions & 10 deletions daemon/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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[]}")
}

0 comments on commit e9bef66

Please sign in to comment.