diff options
-rw-r--r-- | libpod/runtime.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 956cc7275..74328bed7 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -211,6 +211,20 @@ func (r *Runtime) Shutdown(force bool) error { r.valid = false + // Shutdown all containers if --force is given + if force { + ctrs, err := r.state.AllContainers() + if err !=nil { + logrus.Errorf("Error retrieving containers from database: %v", err) + } else { + for _, ctr := range ctrs { + if err := ctr.Stop(ctrRemoveTimeout); err != nil { + logrus.Errorf("Error stopping container %s: %v", ctr.ID(), err) + } + } + } + } + _, err := r.store.Shutdown(force) if err != nil { return err |