-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for anonymous volumes to podman run -v
#4287
Add support for anonymous volumes to podman run -v
#4287
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mheon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Needs tests and manpage adjustments still. Will hit those after lunch. |
7a1f71d
to
86b57a7
Compare
Docs done, test added. Want to add a few more around removing containers with -v and volumes being retained / not being retained. |
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: containers#4276 Signed-off-by: Matthew Heon <[email protected]>
86b57a7
to
0d62391
Compare
Alright, tests are all done. I think this is ready. |
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the volume from this container is shared with another container?
Everything looks good, but I am wondering about the force removal of volumes. |
It only removes anonymous volumes, so volumes you gave a name to will stick
around. In the current implementation, for anonymous volumes, we refuse to
remove if they are used by another container, but if that container becomes
the only container using the volume, it will remove it with 'podman rm
--volumes'.
…On Sat, Oct 19, 2019, 06:39 Daniel J Walsh ***@***.***> wrote:
Everything looks good, but I am wondering about the force removal of
volumes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4287>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3AOCGSVJS55BJHR4GTXN3QPLPUTANCNFSM4JB3N5YA>
.
|
LGTM |
/lgtm |
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
andpodman 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 havetestvol
survive the container being removed bypodman rm -v
.The sum total of these changes let us turn on volume removal in
--rm
by default.Fixes: #4276