Skip to content

Conversation

@ygalblum
Copy link
Contributor

@ygalblum ygalblum commented Jan 6, 2026

Add a new --volume-mode flag that controls behavior when a named volume doesn't exist during container or pod creation.

Supported modes:

  • create (default): auto-create missing named volumes
  • fail: return an error if the volume doesn't exist

The flag is available on: podman create, podman run, podman pod create, and podman pod clone.

See: #27862

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

volume-mode: New command line argument for run, create and pod create to instruct podman to fail when a named volume does not exist instead of creating one.

Add a new --volume-mode flag that controls behavior when a named volume
doesn't exist during container or pod creation.

Supported modes:
- create (default): auto-create missing named volumes
- fail: return an error if the volume doesn't exist

The flag is available on: podman create, podman run, podman pod create,
and podman pod clone.

See: containers#27862
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want a new cli option for this? Would it not be bvetter to pass this on a per volume basis as volume option? --volume name:/dest:nocreate or something like this.

}
// Volume does not exist - check if we should fail
if ctr.config.VolumeMode == define.VolumeModeFail {
return nil, fmt.Errorf("volume %s does not exist and --volume-mode is set to fail: %w", vol.Name, define.ErrNoSuchVolume)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error messages in the backend logic like here should not refer to the cli names, we might be called via rest API, etc.. where these names don't make sense

@ygalblum
Copy link
Contributor Author

ygalblum commented Jan 6, 2026

Do we really want a new cli option for this? Would it not be better to pass this on a per volume basis as volume option? --volume name:/dest:nocreate or something like this.

@mheon and I discussed this question and we also weren't sure if this should be global or volume specific. I don't mind changing it if you think that would be better.

@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@Luap99
Copy link
Member

Luap99 commented Jan 6, 2026

Do we really want a new cli option for this? Would it not be better to pass this on a per volume basis as volume option? --volume name:/dest:nocreate or something like this.

@mheon and I discussed this question and we also weren't sure if this should be global or volume specific. I don't mind changing it if you think that would be better.

I don't care to strongly either way, --volume-mode as name doesn't sound to easy to grasp what it is about to me. i.e. we have something somewhat related with --image-volume. But I cannot offer a better name so I guess --volume-mode is the best choice we have.

@ygalblum ygalblum added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants