summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-28 11:26:06 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-29 12:15:15 +0000
commit4f8fe2b810f5ed25308bc9be0edc6ace3fac0f64 (patch)
tree2f0bbffe3a9d61de6cf896216e2621d46b0c78b5 /libpod
parent0e3dd5f6877db7eed33319176f5e9a63fbefc4db (diff)
downloadpodman-4f8fe2b810f5ed25308bc9be0edc6ace3fac0f64.tar.gz
podman-4f8fe2b810f5ed25308bc9be0edc6ace3fac0f64.tar.bz2
podman-4f8fe2b810f5ed25308bc9be0edc6ace3fac0f64.zip
Shut down containers when force stopping the runtime
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #68 Approved by: rhatdan
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime.go14
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