From 4f8fe2b810f5ed25308bc9be0edc6ace3fac0f64 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 28 Nov 2017 11:26:06 -0500 Subject: Shut down containers when force stopping the runtime Signed-off-by: Matthew Heon Closes: #68 Approved by: rhatdan --- libpod/runtime.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libpod') 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 -- cgit v1.2.3-54-g00ecf