summaryrefslogtreecommitdiff
path: root/pkg/adapter
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-10-17 11:25:28 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-10-17 13:18:17 -0400
commit0d623914d01bcbc10beebf2db966e17da215dfbb (patch)
tree00ef58cddd025309918465e447d34bd5f26b644d /pkg/adapter
parentd7cbcfadd07e9c79831e51de294b307b00292d49 (diff)
downloadpodman-0d623914d01bcbc10beebf2db966e17da215dfbb.tar.gz
podman-0d623914d01bcbc10beebf2db966e17da215dfbb.tar.bz2
podman-0d623914d01bcbc10beebf2db966e17da215dfbb.zip
Add support for anonymous volumes to `podman run -v`
Previously, when `podman run` encountered a volume mount without separate source and destination (e.g. `-v /run`) we would assume that both were the same - a bind mount of `/run` on the host to `/run` in the container. However, this does not match Docker's behavior - in Docker, this makes an anonymous named volume that will be mounted at `/run`. We already have (more limited) support for these anonymous volumes in the form of image volumes. Extend this support to allow it to be used with user-created volumes coming in from the `-v` flag. This change also affects how named volumes created by the container but given names are treated by `podman run --rm` and `podman rm -v`. Previously, they would be removed with the container in these cases, but this did not match Docker's behaviour. Docker only removed anonymous volumes. With this patch we move to that model as well; `podman run -v testvol:/test` will not have `testvol` survive the container being removed by `podman rm -v`. The sum total of these changes let us turn on volume removal in `--rm` by default. Fixes: #4276 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/adapter')
-rw-r--r--pkg/adapter/containers.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 12fd98486..a39a345f1 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -437,7 +437,7 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode
}
if c.IsSet("rm") {
- if err := r.Runtime.RemoveContainer(ctx, ctr, false, false); err != nil {
+ if err := r.Runtime.RemoveContainer(ctx, ctr, false, true); err != nil {
logrus.Errorf("Error removing container %s: %v", ctr.ID(), err)
}
}
@@ -1051,7 +1051,7 @@ func (r *LocalRuntime) CleanupContainers(ctx context.Context, cli *cliconfig.Cle
// Only used when cleaning up containers
func removeContainer(ctx context.Context, ctr *libpod.Container, runtime *LocalRuntime) error {
- if err := runtime.RemoveContainer(ctx, ctr, false, false); err != nil {
+ if err := runtime.RemoveContainer(ctx, ctr, false, true); err != nil {
return errors.Wrapf(err, "failed to cleanup and remove container %v", ctr.ID())
}
return nil