Fix LogConfig.Config in inspect
Also add test for daemon-wide log-opt. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
960791ba60
commit
3f61002b05
2 changed files with 13 additions and 1 deletions
|
@ -41,7 +41,7 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
|
|||
hostConfig.LogConfig.Type = daemon.defaultLogConfig.Type
|
||||
}
|
||||
|
||||
if hostConfig.LogConfig.Config == nil {
|
||||
if len(hostConfig.LogConfig.Config) == 0 {
|
||||
hostConfig.LogConfig.Config = daemon.defaultLogConfig.Config
|
||||
}
|
||||
|
||||
|
|
|
@ -1558,3 +1558,15 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedSyslogAddress(c *check.C) {
|
|||
c.Fatalf("Expected 'Error starting daemon' message; but doesn't exist in log: %q, err: %v", out, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
|
||||
c.Assert(s.d.Start("--log-driver=json-file", "--log-opt=max-size=1k"), check.IsNil)
|
||||
out, err := s.d.Cmd("run", "-d", "--name=logtest", "busybox", "top")
|
||||
c.Assert(err, check.IsNil, check.Commentf("Output: %s, err: %v", out, err))
|
||||
out, err = s.d.Cmd("inspect", "-f", "{{ .HostConfig.LogConfig.Config }}", "logtest")
|
||||
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
||||
cfg := strings.TrimSpace(out)
|
||||
if cfg != "map[max-size:1k]" {
|
||||
c.Fatalf("Unexpected log-opt: %s, expected map[max-size:1k]", cfg)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue