Fix container.Update

This commit is contained in:
Joel Elkins 2022-07-29 23:06:31 -05:00
parent 82aa749928
commit 515929fd8f

View File

@ -287,7 +287,7 @@ func (c *Container) IsCreated() bool {
func (c *Container) UpdateCommands() command.Commands {
wasRunning := false
return command.Commands{
command.NewFunc("do_update_and_stop", func() error {
command.NewFunc("pull_and_stop", func() error {
err := c.pull()
if err != nil {
return err
@ -295,18 +295,11 @@ func (c *Container) UpdateCommands() command.Commands {
wasRunning = c.cdata != nil && c.cdata.State != nil && c.cdata.State.Running
if wasRunning {
var timeout uint = 10
err := containers.Stop(c.conn, c.cdata.ID, &containers.StopOptions{Timeout: &timeout})
if err != nil {
return err
}
_, err = containers.Remove(c.conn, c.cdata.ID, nil)
if err != nil {
return err
}
c.cdata = nil
_ = containers.Stop(c.conn, c.cdata.ID, &containers.StopOptions{Timeout: &timeout})
}
return nil
}),
command.NewSet(c.DestroyCommands()),
command.NewSet(c.CreateCommands()),
command.NewConditional("restart_if_was_running",
func() bool { return wasRunning },