mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
04cc6c6aa4
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
18 lines
409 B
Go
18 lines
409 B
Go
package daemon
|
|
|
|
import "fmt"
|
|
|
|
func (daemon *Daemon) ContainerStop(name string, seconds int) error {
|
|
container, err := daemon.Get(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !container.IsRunning() {
|
|
return fmt.Errorf("Container already stopped")
|
|
}
|
|
if err := container.Stop(seconds); err != nil {
|
|
return fmt.Errorf("Cannot stop container %s: %s\n", name, err)
|
|
}
|
|
container.LogEvent("stop")
|
|
return nil
|
|
}
|