daemon/container: stream & decode JSON

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
unclejack 2014-11-04 15:43:58 +02:00
parent b68d7d39bc
commit 4bc28f4e6b
1 changed files with 6 additions and 2 deletions

View File

@ -102,13 +102,17 @@ func (container *Container) FromDisk() error {
return err
}
data, err := ioutil.ReadFile(pth)
jsonSource, err := os.Open(pth)
if err != nil {
return err
}
defer jsonSource.Close()
dec := json.NewDecoder(jsonSource)
// Load container settings
// udp broke compat of docker.PortMapping, but it's not used when loading a container, we can skip it
if err := json.Unmarshal(data, container); err != nil && !strings.Contains(err.Error(), "docker.PortMapping") {
if err := dec.Decode(container); err != nil && !strings.Contains(err.Error(), "docker.PortMapping") {
return err
}