Skip to content

Commit

Permalink
Merge pull request #2132 from knightXun/restartCount
Browse files Browse the repository at this point in the history
bugfix: cannot get restartCount and let restartCount++ after restart container
  • Loading branch information
allencloud authored Aug 23, 2018
2 parents b9724f2 + a328bbc commit 90f165a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
17 changes: 9 additions & 8 deletions apis/server/container_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 13 additions & 1 deletion daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 90f165a

Please sign in to comment.