Pause pauses the container, if its state is RUNNING or CREATED, changing its state to PAUSED. If the state is already PAUSED, does nothing.
()
| 759 | // Pause pauses the container, if its state is RUNNING or CREATED, changing |
| 760 | // its state to PAUSED. If the state is already PAUSED, does nothing. |
| 761 | func (c *Container) Pause() error { |
| 762 | c.m.Lock() |
| 763 | defer c.m.Unlock() |
| 764 | status, err := c.currentStatus() |
| 765 | if err != nil { |
| 766 | return err |
| 767 | } |
| 768 | switch status { |
| 769 | case Running, Created: |
| 770 | if err := c.cgroupManager.Freeze(cgroups.Frozen); err != nil { |
| 771 | return err |
| 772 | } |
| 773 | return c.state.transition(&pausedState{ |
| 774 | c: c, |
| 775 | }) |
| 776 | } |
| 777 | return ErrNotRunning |
| 778 | } |
| 779 | |
| 780 | // Resume resumes the execution of any user processes in the |
| 781 | // container before setting the container state to RUNNING. |