github.com/rawahars/moby@v24.0.4+incompatible/daemon/unpause.go (about) 1 package daemon // import "github.com/docker/docker/daemon" 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/docker/docker/container" 8 "github.com/sirupsen/logrus" 9 ) 10 11 // ContainerUnpause unpauses a container 12 func (daemon *Daemon) ContainerUnpause(name string) error { 13 ctr, err := daemon.GetContainer(name) 14 if err != nil { 15 return err 16 } 17 return daemon.containerUnpause(ctr) 18 } 19 20 // containerUnpause resumes the container execution after the container is paused. 21 func (daemon *Daemon) containerUnpause(ctr *container.Container) error { 22 ctr.Lock() 23 defer ctr.Unlock() 24 25 // We cannot unpause the container which is not paused 26 if !ctr.Paused { 27 return fmt.Errorf("Container %s is not paused", ctr.ID) 28 } 29 tsk, err := ctr.GetRunningTask() 30 if err != nil { 31 return err 32 } 33 34 if err := tsk.Resume(context.Background()); err != nil { 35 return fmt.Errorf("Cannot unpause container %s: %s", ctr.ID, err) 36 } 37 38 ctr.Paused = false 39 daemon.setStateCounter(ctr) 40 daemon.updateHealthMonitor(ctr) 41 daemon.LogContainerEvent(ctr, "unpause") 42 43 if err := ctr.CheckpointTo(daemon.containersReplica); err != nil { 44 logrus.WithError(err).Warn("could not save container to disk") 45 } 46 47 return nil 48 }