feat: do no execute pre/post update commands on linked containers

This commit is contained in:
Alexandre Menif 2018-12-19 22:01:11 +01:00
parent 611c1359ab
commit cbf6d22b0c
3 changed files with 81 additions and 11 deletions

View file

@ -29,6 +29,7 @@ func NewContainer(containerInfo *types.ContainerJSON, imageInfo *types.ImageInsp
// Container represents a running Docker container.
type Container struct {
Linked bool
Stale bool
containerInfo *types.ContainerJSON
@ -141,6 +142,12 @@ func (c Container) PostUpdateCommand() string {
return ""
}
// ToRestart return whether the container should be restarted, either because
// is stale or linked to another stale container.
func (c Container) ToRestart() bool {
return c.Stale || c.Linked
}
// Ideally, we'd just be able to take the ContainerConfig from the old container
// and use it as the starting point for creating the new container; however,
// the ContainerConfig that comes back from the Inspect call merges the default