containers/podman

"volume create" fails if a volume already exists, unlike Docker

Open

#26,657 opened on 2025年7月17日

GitHub で見る
 (8 comments) (3 reactions) (0 assignees)Go (3,107 forks)batch import
ContribfestGood First Issuekind/bugtriagedvolunteers-wanted

Repository metrics

Stars
 (31,686 stars)
PR merge metrics
 (30d に merged PR はありません)

説明

Issue Description

Switching from Docker to Podman, a program - which wanted to create a volume if it did not already exist, to ensure it existed - started failing.

In short, the command docker volume create foo started failing if the volume already exists, when docker is an alias for podman.

The cause seems to be that Docker allows the volume to already exist by default, per https://docs.docker.com/reference/cli/docker/volume/create/:

If you specify a volume name already in use on the current driver, Docker assumes you want to reuse the existing volume and doesn't return an error.

However, podman is the opposite, per https://docs.podman.io/en/latest/markdown/podman-volume-create.1.html:

--ignore Don’t fail if the named volume already exists, instead just print the name. Note that the new options are not applied to the existing volume.

I get that exact compatibility of flags and semantics is perhaps hard to do, but I'm not sure how to make this program work on both Docker and Podman if they have exactly opposite defaults, and only Podman has the "ignore" flag.

Steps to reproduce the issue

Steps to reproduce the issue

  1. podman volume create foo
  2. podman volume create foo

Describe the results you received

$ podman volume create foo
foo
$ podman volume create foo
Error: volume with name foo already exists: volume already exists

Describe the results you expected

Both commands to succeed, like Docker.

podman info output

host:
  arch: amd64
  buildahVersion: 1.40.1
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.13-1.fc42.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.13, commit: '
  cpuUtilization:
    idlePercent: 98.48
    systemPercent: 0.28
    userPercent: 1.24
  cpus: 24
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: sway-atomic
    version: "42"
  eventLogger: journald
  freeLocks: 2046
  hostname: fw13
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 6.15.6-200.fc42.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 30253932544
  memTotal: 50274447360
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.15.0-1.fc42.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.15.0
    package: netavark-1.15.2-1.fc42.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.15.2
  ociRuntime:
    name: crun
    package: crun-1.22-1.fc42.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.22
      commit: 4de19b63a85efd9ea8503452179c371181750130
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20250611.g0293c6f-1.fc42.x86_64
    version: |
      pasta 0^20250611.g0293c6f-1.fc42.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.3.1-2.fc42.x86_64
    version: |-
      slirp4netns version 1.3.1
      commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236
      libslirp: 4.8.0
      SLIRP_CONFIG_VERSION_MAX: 5
      libseccomp: 2.5.5
  swapFree: 8589930496
  swapTotal: 8589930496
  uptime: 19h 20m 34.00s (Approximately 0.79 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /var/home/mvdan/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/mvdan/.local/share/containers/storage
  graphRootAllocated: 1998678130688
  graphRootUsed: 254552780800
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 150
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /var/home/mvdan/.local/share/containers/storage/volumes
version:
  APIVersion: 5.5.2
  BuildOrigin: Fedora Project
  Built: 1750723200
  BuiltTime: Tue Jun 24 01:00:00 2025
  GitCommit: e7d8226745ba07a64b7176a7f128e4ef53225a0e
  GoVersion: go1.24.4
  Os: linux
  OsArch: linux/amd64
  Version: 5.5.2

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

No response

Additional information

No response

コントリビューターガイド