From cf1a6c08fa03aa7020f8f5b414bb9349a9c8371a Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Fri, 30 Oct 2015 14:45:35 -0700 Subject: [PATCH] Use json.Encoder for container.writeHostConfig Signed-off-by: Alexander Morozov --- daemon/container.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/daemon/container.go b/daemon/container.go index 170726fd1e..0c2928ed7a 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -165,17 +164,18 @@ func (container *Container) readHostConfig() error { } func (container *Container) writeHostConfig() error { - data, err := json.Marshal(container.hostConfig) - if err != nil { - return err - } - pth, err := container.hostConfigPath() if err != nil { return err } - return ioutil.WriteFile(pth, data, 0666) + f, err := os.Create(pth) + if err != nil { + return err + } + defer f.Close() + + return json.NewEncoder(f).Encode(&container.hostConfig) } func (container *Container) logEvent(action string) {