Instead of using `MNT_DETACH` to unmount the container's mqueue/shm
mounts, force it... but only on daemon init and shutdown.
This makes sure that these IPC mounts are cleaned up even when the
daemon is killed.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -337,7 +337,7 @@ func (streamConfig *streamConfig) StderrPipe() io.ReadCloser {
|
| 337 | 337 |
func (container *Container) cleanup() {
|
| 338 | 338 |
container.releaseNetwork() |
| 339 | 339 |
|
| 340 |
- if err := container.unmountIpcMounts(); err != nil {
|
|
| 340 |
+ if err := container.unmountIpcMounts(detachMounted); err != nil {
|
|
| 341 | 341 |
logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err)
|
| 342 | 342 |
} |
| 343 | 343 |
|
| ... | ... |
@@ -1359,7 +1359,7 @@ func (container *Container) setupIpcDirs() error {
|
| 1359 | 1359 |
return nil |
| 1360 | 1360 |
} |
| 1361 | 1361 |
|
| 1362 |
-func (container *Container) unmountIpcMounts() error {
|
|
| 1362 |
+func (container *Container) unmountIpcMounts(unmount func(pth string) error) error {
|
|
| 1363 | 1363 |
if container.hostConfig.IpcMode.IsContainer() || container.hostConfig.IpcMode.IsHost() {
|
| 1364 | 1364 |
return nil |
| 1365 | 1365 |
} |
| ... | ... |
@@ -1372,7 +1372,7 @@ func (container *Container) unmountIpcMounts() error {
|
| 1372 | 1372 |
logrus.Error(err) |
| 1373 | 1373 |
errors = append(errors, err.Error()) |
| 1374 | 1374 |
} else {
|
| 1375 |
- if err := detachMounted(shmPath); err != nil {
|
|
| 1375 |
+ if err := unmount(shmPath); err != nil {
|
|
| 1376 | 1376 |
logrus.Errorf("failed to umount %s: %v", shmPath, err)
|
| 1377 | 1377 |
errors = append(errors, err.Error()) |
| 1378 | 1378 |
} |
| ... | ... |
@@ -1386,7 +1386,7 @@ func (container *Container) unmountIpcMounts() error {
|
| 1386 | 1386 |
logrus.Error(err) |
| 1387 | 1387 |
errors = append(errors, err.Error()) |
| 1388 | 1388 |
} else {
|
| 1389 |
- if err := detachMounted(mqueuePath); err != nil {
|
|
| 1389 |
+ if err := unmount(mqueuePath); err != nil {
|
|
| 1390 | 1390 |
logrus.Errorf("failed to umount %s: %v", mqueuePath, err)
|
| 1391 | 1391 |
errors = append(errors, err.Error()) |
| 1392 | 1392 |
} |
| ... | ... |
@@ -185,7 +185,11 @@ func (container *Container) setupIpcDirs() error {
|
| 185 | 185 |
return nil |
| 186 | 186 |
} |
| 187 | 187 |
|
| 188 |
-func (container *Container) unmountIpcMounts() error {
|
|
| 188 |
+func (container *Container) unmountIpcMounts(unmount func(pth string) error) error {
|
|
| 189 |
+ return nil |
|
| 190 |
+} |
|
| 191 |
+ |
|
| 192 |
+func detachMounted(path string) error {
|
|
| 189 | 193 |
return nil |
| 190 | 194 |
} |
| 191 | 195 |
|
| ... | ... |
@@ -39,6 +39,7 @@ import ( |
| 39 | 39 |
"github.com/docker/docker/pkg/idtools" |
| 40 | 40 |
"github.com/docker/docker/pkg/ioutils" |
| 41 | 41 |
"github.com/docker/docker/pkg/jsonmessage" |
| 42 |
+ "github.com/docker/docker/pkg/mount" |
|
| 42 | 43 |
"github.com/docker/docker/pkg/namesgenerator" |
| 43 | 44 |
"github.com/docker/docker/pkg/nat" |
| 44 | 45 |
"github.com/docker/docker/pkg/parsers/filters" |
| ... | ... |
@@ -223,7 +224,7 @@ func (daemon *Daemon) Register(container *Container) error {
|
| 223 | 223 |
} |
| 224 | 224 |
daemon.execDriver.Terminate(cmd) |
| 225 | 225 |
|
| 226 |
- if err := container.unmountIpcMounts(); err != nil {
|
|
| 226 |
+ if err := container.unmountIpcMounts(mount.Unmount); err != nil {
|
|
| 227 | 227 |
logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err)
|
| 228 | 228 |
} |
| 229 | 229 |
if err := container.Unmount(); err != nil {
|
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 |
+ "github.com/docker/docker/pkg/mount" |
|
| 12 | 13 |
) |
| 13 | 14 |
|
| 14 | 15 |
// cleanupMounts umounts shm/mqueue mounts for old containers |
| ... | ... |
@@ -20,7 +21,7 @@ func (daemon *Daemon) cleanupMounts() error {
|
| 20 | 20 |
} |
| 21 | 21 |
defer f.Close() |
| 22 | 22 |
|
| 23 |
- return daemon.cleanupMountsFromReader(f, detachMounted) |
|
| 23 |
+ return daemon.cleanupMountsFromReader(f, mount.Unmount) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
func (daemon *Daemon) cleanupMountsFromReader(reader io.Reader, unmount func(target string) error) error {
|