diff --git a/cluster/engine.go b/cluster/engine.go index f3422d3b6a..0b2fc2daef 100644 --- a/cluster/engine.go +++ b/cluster/engine.go @@ -728,6 +728,13 @@ func (e *Engine) refreshVolume(IDOrName string) error { // true, each container will be inspected. // FIXME: unexport this method after mesos scheduler stops using it directly func (e *Engine) RefreshContainers(full bool) error { + oldContainers := []string{} + e.RLock() + for id := range e.containers { + oldContainers = append(oldContainers, id) + } + e.RUnlock() + opts := types.ContainerListOptions{ All: true, Size: false, @@ -750,7 +757,14 @@ func (e *Engine) RefreshContainers(full bool) error { e.Lock() defer e.Unlock() - e.containers = merged + for id, c := range merged { + e.containers[id] = c + } + for _, id := range oldContainers { + if _, exists := merged[id]; !exists { + delete(e.containers, id) + } + } return nil } diff --git a/cluster/swarm/cluster.go b/cluster/swarm/cluster.go index 9b691a013a..3992351d7a 100644 --- a/cluster/swarm/cluster.go +++ b/cluster/swarm/cluster.go @@ -41,8 +41,9 @@ func (p *pendingContainer) ToContainer() *cluster.Container { Config: p.Config, Info: types.ContainerJSON{ ContainerJSONBase: &types.ContainerJSONBase{ - HostConfig: &containertypes.HostConfig{}, + HostConfig: &p.Config.HostConfig, }, + Config: &p.Config.Config, }, Engine: p.Engine, }