moby/container
Brian Goff 9a2d0bc3ad Fix uneccessary calls to volume.Unmount()
Fixes #22564

When an error occurs on mount, there should not be any call later to
unmount. This can throw off refcounting in the underlying driver
unexpectedly.

Consider these two cases:

```
$ docker run -v foo:/bar busybox true
```

```
$ docker run -v foo:/bar -w /foo busybox true
```

In the first case, if mounting `foo` fails, the volume driver will not
get a call to unmount (this is the incorrect behavior).

In the second case, the volume driver will not get a call to unmount
(correct behavior).

This occurs because in the first case, `/bar` does not exist in the
container, and as such there is no call to `volume.Mount()` during the
`create` phase. It will error out during the `start` phase.

In the second case `/bar` is created before dealing with the volume
because of the `-w`. Because of this, when the volume is being setup
docker will try to copy the image path contents in the volume, in which
case it will attempt to mount the volume and fail. This happens during
the `create` phase. This makes it so the container will not be created
(or at least fully created) and the user gets the error on `create`
instead of `start`. The error handling is different in these two phases.

Changed to only send `unmount` if the volume is mounted.

While investigating the cause of the reported issue I found some odd
behavior in unmount calls so I've cleaned those up a bit here as well.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-10 14:04:08 -05:00
..
archive.go Add engine-api types to docker 2016-09-07 11:05:58 -07:00
container.go Fix uneccessary calls to volume.Unmount() 2016-11-10 14:04:08 -05:00
container_linux.go Add functional support for Docker sub commands on Solaris 2016-11-07 09:06:34 -08:00
container_notlinux.go add SecretMount and UnmountSecrets methods for non-Linux 2016-11-09 14:27:43 -05:00
container_unit_test.go Update docker stop and docker restart to allow not specifying timeout and use the one specified at container creation time. 2016-10-17 12:53:35 -07:00
container_unix.go Fix uneccessary calls to volume.Unmount() 2016-11-10 14:04:08 -05:00
container_windows.go Fix uneccessary calls to volume.Unmount() 2016-11-10 14:04:08 -05:00
health.go Add engine-api types to docker 2016-09-07 11:05:58 -07:00
history.go Release memoryStore locks before filter/apply 2016-05-23 11:45:04 -07:00
memory_store.go Add functional support for Docker sub commands on Solaris 2016-11-07 09:06:34 -08:00
memory_store_test.go Extract container store from the daemon. 2016-01-19 13:21:41 -05:00
monitor.go *: fix logrus.Warn[f] 2016-06-11 19:42:38 +02:00
mounts_unix.go Replace execdrivers with containerd implementation 2016-03-18 13:38:32 -07:00
mounts_windows.go Windows libcontainerd implementation 2016-03-18 13:38:41 -07:00
state.go Adds container health support to docker ps filter 2016-10-28 15:43:04 -04:00
state_solaris.go Re-export container state's ExitCode and Error fields 2016-08-30 14:17:09 -07:00
state_test.go Adds container health support to docker ps filter 2016-10-28 15:43:04 -04:00
state_unix.go Re-export container state's ExitCode and Error fields 2016-08-30 14:17:09 -07:00
state_windows.go Re-export container state's ExitCode and Error fields 2016-08-30 14:17:09 -07:00
store.go Extract container store from the daemon. 2016-01-19 13:21:41 -05:00