Browse Source

Fix `inspect` output when no log driver specified

Config options were being ignored in the inspect output when no driver
was specified.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Brian Goff 10 years ago
parent
commit
2f2779b6a5
2 changed files with 22 additions and 1 deletions
  1. 5 1
      daemon/inspect.go
  2. 17 0
      integration-cli/docker_cli_inspect_test.go

+ 5 - 1
daemon/inspect.go

@@ -38,7 +38,11 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
 	// we need this trick to preserve empty log driver, so
 	// we need this trick to preserve empty log driver, so
 	// container will use daemon defaults even if daemon change them
 	// container will use daemon defaults even if daemon change them
 	if hostConfig.LogConfig.Type == "" {
 	if hostConfig.LogConfig.Type == "" {
-		hostConfig.LogConfig = daemon.defaultLogConfig
+		hostConfig.LogConfig.Type = daemon.defaultLogConfig.Type
+	}
+
+	if hostConfig.LogConfig.Config == nil {
+		hostConfig.LogConfig.Config = daemon.defaultLogConfig.Config
 	}
 	}
 
 
 	containerState := &types.ContainerState{
 	containerState := &types.ContainerState{

+ 17 - 0
integration-cli/docker_cli_inspect_test.go

@@ -1,6 +1,7 @@
 package main
 package main
 
 
 import (
 import (
+	"encoding/json"
 	"fmt"
 	"fmt"
 	"os/exec"
 	"os/exec"
 	"strconv"
 	"strconv"
@@ -8,6 +9,7 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
+	"github.com/docker/docker/runconfig"
 	"github.com/go-check/check"
 	"github.com/go-check/check"
 )
 )
 
 
@@ -286,3 +288,18 @@ func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
 	_, err = time.Parse(time.RFC3339Nano, created)
 	_, err = time.Parse(time.RFC3339Nano, created)
 	c.Assert(err, check.IsNil)
 	c.Assert(err, check.IsNil)
 }
 }
+
+// #15633
+func (s *DockerSuite) TestInspectLogConfigNoType(c *check.C) {
+	dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox")
+	var logConfig runconfig.LogConfig
+
+	out, err := inspectFieldJSON("test", "HostConfig.LogConfig")
+	c.Assert(err, check.IsNil)
+
+	err = json.NewDecoder(strings.NewReader(out)).Decode(&logConfig)
+	c.Assert(err, check.IsNil)
+
+	c.Assert(logConfig.Type, check.Equals, "json-file")
+	c.Assert(logConfig.Config["max-file"], check.Equals, "42", check.Commentf("%v", logConfig))
+}