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:
parent
bba762b192
commit
2f2779b6a5
2 changed files with 22 additions and 1 deletions
|
@ -38,7 +38,11 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
|
|||
// we need this trick to preserve empty log driver, so
|
||||
// container will use daemon defaults even if daemon change them
|
||||
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{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
|
@ -8,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
|
@ -286,3 +288,18 @@ func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
|
|||
_, err = time.Parse(time.RFC3339Nano, created)
|
||||
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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue