diff --git a/apis/server/container_bridge.go b/apis/server/container_bridge.go index 9a04b1a82..543bdb303 100644 --- a/apis/server/container_bridge.go +++ b/apis/server/container_bridge.go @@ -74,14 +74,15 @@ func (s *Server) getContainer(ctx context.Context, rw http.ResponseWriter, req * } container := types.ContainerJSON{ - ID: c.ID, - Name: c.Name, - Image: c.Config.Image, - Created: c.Created, - State: c.State, - Config: c.Config, - HostConfig: c.HostConfig, - Snapshotter: c.Snapshotter, + ID: c.ID, + Name: c.Name, + Image: c.Config.Image, + Created: c.Created, + State: c.State, + Config: c.Config, + HostConfig: c.HostConfig, + Snapshotter: c.Snapshotter, + RestartCount: c.RestartCount, GraphDriver: &types.GraphDriverData{ Name: c.Snapshotter.Name, Data: c.Snapshotter.Data, diff --git a/daemon/mgr/container.go b/daemon/mgr/container.go index eed8fd815..dd9da2546 100644 --- a/daemon/mgr/container.go +++ b/daemon/mgr/container.go @@ -796,8 +796,20 @@ func (mgr *ContainerManager) Restart(ctx context.Context, name string, timeout i } logrus.Debugf("start container %s when restarting", c.ID) + + //let restartCount++ + restartCount := c.RestartCount + 1 + // start container - return mgr.start(ctx, c, &types.ContainerStartOptions{}) + err = mgr.start(ctx, c, &types.ContainerStartOptions{}) + if err != nil { + return err + } + + c.RestartCount = restartCount + + logrus.Debugf("container %s restartCount is %d", c.ID, c.RestartCount) + return c.Write(mgr.Store) } // Pause pauses a running container.