diff --git a/daemon/logs.go b/daemon/logs.go index e0da46d9e4..1b285c691d 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -150,6 +150,10 @@ func (daemon *Daemon) mergeAndVerifyLogConfig(cfg *containertypes.LogConfig) err cfg.Type = daemon.defaultLogConfig.Type } + if cfg.Config == nil { + cfg.Config = make(map[string]string) + } + if cfg.Type == daemon.defaultLogConfig.Type { for k, v := range daemon.defaultLogConfig.Config { if _, ok := cfg.Config[k]; !ok { diff --git a/daemon/logs_test.go b/daemon/logs_test.go new file mode 100644 index 0000000000..f0c6f6e1e9 --- /dev/null +++ b/daemon/logs_test.go @@ -0,0 +1,15 @@ +package daemon + +import ( + "testing" + + containertypes "github.com/docker/engine-api/types/container" +) + +func TestMergeAndVerifyLogConfigNilConfig(t *testing.T) { + d := &Daemon{defaultLogConfig: containertypes.LogConfig{Type: "json-file", Config: map[string]string{"max-file": "1"}}} + cfg := containertypes.LogConfig{Type: d.defaultLogConfig.Type} + if err := d.mergeAndVerifyLogConfig(&cfg); err != nil { + t.Fatal(err) + } +}