This patch makes sure daemon resources are cleaned up on shutdown if
there are no running containers.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -652,8 +652,12 @@ func (daemon *Daemon) Shutdown() error {
|
| 652 | 652 |
// Keep mounts and networking running on daemon shutdown if |
| 653 | 653 |
// we are to keep containers running and restore them. |
| 654 | 654 |
if daemon.configStore.LiveRestore {
|
| 655 |
- return nil |
|
| 655 |
+ // check if there are any running containers, if none we should do some cleanup |
|
| 656 |
+ if ls, err := daemon.Containers(&types.ContainerListOptions{}); len(ls) != 0 || err != nil {
|
|
| 657 |
+ return nil |
|
| 658 |
+ } |
|
| 656 | 659 |
} |
| 660 |
+ |
|
| 657 | 661 |
if daemon.containers != nil {
|
| 658 | 662 |
logrus.Debug("starting clean shutdown of all containers...")
|
| 659 | 663 |
daemon.containers.ApplyAll(func(c *container.Container) {
|