diff --git a/container.go b/container.go index a2e0c7049c..7acbc7ba69 100644 --- a/container.go +++ b/container.go @@ -265,7 +265,7 @@ func (container *Container) ToDisk() (err error) { return ioutil.WriteFile(container.jsonPath(), data, 0666) } -func (container *Container) ReadTempHostConfig() (*HostConfig, error) { +func (container *Container) ReadHostConfig() (*HostConfig, error) { data, err := ioutil.ReadFile(container.hostConfigPath()) if err != nil { return &HostConfig{}, err @@ -278,9 +278,6 @@ func (container *Container) ReadTempHostConfig() (*HostConfig, error) { } func (container *Container) SaveHostConfig(hostConfig *HostConfig) (err error) { - if hostConfig == nil { - return os.Remove(container.hostConfigPath()) - } data, err := json.Marshal(hostConfig) if err != nil { return @@ -491,6 +488,9 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s func (container *Container) Start(hostConfig *HostConfig) error { container.State.lock() defer container.State.unlock() + if len(hostConfig.Binds) == 0 { + hostConfig, _ = container.ReadHostConfig() + } if container.State.Running { return fmt.Errorf("The container %s is already running.", container.ID) @@ -815,8 +815,6 @@ func (container *Container) monitor() { // FIXME: why are we serializing running state to disk in the first place? //log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err) } - // Remove temp host config - container.SaveHostConfig(nil) } func (container *Container) kill() error { diff --git a/runtime.go b/runtime.go index 7e728cfe6f..d283540abb 100644 --- a/runtime.go +++ b/runtime.go @@ -144,8 +144,7 @@ func (runtime *Runtime) Register(container *Container) error { utils.Debugf("Restarting") container.State.Ghost = false container.State.setStopped(0) - // assume empty host config - hostConfig, _ := container.ReadTempHostConfig() + hostConfig := &HostConfig{} if err := container.Start(hostConfig); err != nil { return err } @@ -156,8 +155,6 @@ func (runtime *Runtime) Register(container *Container) error { if err := container.ToDisk(); err != nil { return err } - // remove temp host config - container.SaveHostConfig(nil) } } }