Merge pull request #21961 from yongtang/21956-docker-inspect-log-default-options
Docker inspect gave default log options even when the option is emtpy.
This commit is contained in:
commit
e9bef66021
|
@ -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))
|
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{
|
containerState := &types.ContainerState{
|
||||||
Status: container.State.StateString(),
|
Status: container.State.StateString(),
|
||||||
Running: container.State.Running,
|
Running: container.State.Running,
|
||||||
|
|
|
@ -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 Store: consul://consuladdr:consulport/some/path"))
|
||||||
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: 192.168.56.100:0"))
|
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[]}")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue