mirror of https://github.com/docker/docs.git
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:
parent
b68d7d39bc
commit
4bc28f4e6b
|
@ -102,13 +102,17 @@ func (container *Container) FromDisk() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(pth)
|
jsonSource, err := os.Open(pth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer jsonSource.Close()
|
||||||
|
|
||||||
|
dec := json.NewDecoder(jsonSource)
|
||||||
|
|
||||||
// Load container settings
|
// Load container settings
|
||||||
// udp broke compat of docker.PortMapping, but it's not used when loading a container, we can skip it
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue