Skip to content

Commit

Permalink
Fix LogConfig.Config in inspect
Browse files Browse the repository at this point in the history
Also add test for daemon-wide log-opt.

Signed-off-by: Alexander Morozov <[email protected]>
  • Loading branch information
LK4D4 committed Aug 17, 2015
1 parent 960791b commit 3f61002
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion daemon/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 12 additions & 0 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 3f61002

Please sign in to comment.