1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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>
This commit is contained in:
Brian Goff 2015-08-17 11:35:34 -04:00
parent bba762b192
commit 2f2779b6a5
2 changed files with 22 additions and 1 deletions

View file

@ -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{

View file

@ -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))
}