github.com/containers/podman/v5@v5.1.0-rc1/docs/source/markdown/podman-volume-create.1.md (about)

     1  % podman-volume-create 1
     2  
     3  ## NAME
     4  podman\-volume\-create - Create a new volume
     5  
     6  ## SYNOPSIS
     7  **podman volume create** [*options*] [*name*]
     8  
     9  ## DESCRIPTION
    10  
    11  Creates an empty volume and prepares it to be used by containers. The volume
    12  can be created with a specific name, if a name is not given a random name is
    13  generated. You can add metadata to the volume by using the **--label** flag and
    14  driver options can be set using the **--opt** flag.
    15  
    16  ## OPTIONS
    17  
    18  #### **--driver**, **-d**=*driver*
    19  
    20  Specify the volume driver name (default **local**).
    21  There are two drivers supported by Podman itself: **local** and **image**.
    22  
    23  The **local** driver uses a directory on disk as the backend by default, but can also use the **mount(8)** command to mount a filesystem as the volume if **--opt** is specified.
    24  
    25  The **image** driver uses an image as the backing store of for the volume.
    26  An overlay filesystem is created, which allows changes to the volume to be committed as a new layer on top of the image.
    27  
    28  Using a value other than **local** or **image**, Podman attempts to create the volume using a volume plugin with the given name.
    29  Such plugins must be defined in the **volume_plugins** section of the **[containers.conf(5)](https://github.com/containers/common/blob/main/docs/containers.conf.5.md)** configuration file.
    30  
    31  #### **--help**
    32  
    33  Print usage statement
    34  
    35  #### **--ignore**
    36  
    37  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.
    38  
    39  #### **--label**, **-l**=*label*
    40  
    41  Set metadata for a volume (e.g., --label mykey=value).
    42  
    43  #### **--opt**, **-o**=*option*
    44  
    45  Set driver specific options.
    46  For the default driver, **local**, this allows a volume to be configured to mount a filesystem on the host.
    47  
    48  For the `local` driver the following options are supported: `type`, `device`, `o`, and `[no]copy`.
    49  
    50    - The `type` option sets the type of the filesystem to be mounted, and is equivalent to the `-t` flag to **mount(8)**.
    51    - The `device` option sets the device to be mounted, and is equivalent to the `device` argument to **mount(8)**.
    52    - The `copy` option enables copying files from the container image path where the mount is created to the newly created volume on the first run.  `copy` is the default.
    53  
    54  The `o` option sets options for the mount, and is equivalent to the filesystem
    55  options (also `-o`) passed to **mount(8)** with the following exceptions:
    56  
    57    - The `o` option supports `uid` and `gid` options to set the UID and GID of the created volume that are not normally supported by **mount(8)**.
    58    - The `o` option supports the `size` option to set the maximum size of the created volume, the `inodes` option to set the maximum number of inodes for the volume, and `noquota` to completely disable quota support even for tracking of disk usage.
    59    The `size` option is supported on the "tmpfs" and "xfs[note]" file systems.
    60    The `inodes` option is supported on the "xfs[note]" file systems.
    61    Note: xfs filesystems must be mounted with the `prjquota` flag described in the **xfs_quota(8)** man page. Podman will throw an error if they're not.
    62    - The `o` option supports using volume options other than the UID/GID options with the **local** driver and requires root privileges.
    63    - The `o` options supports the `timeout` option which allows users to set a driver specific timeout in seconds before volume creation fails. For example, **--opt=o=timeout=10** sets a driver timeout of 10 seconds.
    64  
    65  ***Note*** Do not confuse the `--opt,-o` create option with the `-o` mount option.  For example, with `podman volume create`, use `-o=o=uid=1000` *not* `-o=uid=1000`.
    66  
    67  For the **image** driver, the only supported option is `image`, which specifies the image the volume is based on.
    68  This option is mandatory when using the **image** driver.
    69  
    70  When not using the **local** and **image** drivers, the given options are passed directly to the volume plugin. In this case, supported options are dictated by the plugin in question, not Podman.
    71  
    72  ## EXAMPLES
    73  
    74  Create empty volume.
    75  ```
    76  $ podman volume create
    77  ```
    78  
    79  Create empty named volume.
    80  ```
    81  $ podman volume create myvol
    82  ```
    83  
    84  Create empty named volume with specified label.
    85  ```
    86  $ podman volume create --label foo=bar myvol
    87  ```
    88  
    89  Create tmpfs named volume with specified size and mount options.
    90  ```
    91  # podman volume create --opt device=tmpfs --opt type=tmpfs --opt o=size=2M,nodev,noexec myvol
    92  ```
    93  
    94  Create tmpfs named volume testvol with specified options.
    95  ```
    96  # podman volume create --opt device=tmpfs --opt type=tmpfs --opt o=uid=1000,gid=1000 testvol
    97  ```
    98  
    99  Create image named volume using the specified local image in containers/storage.
   100  ```
   101  # podman volume create --driver image --opt image=fedora:latest fedoraVol
   102  ```
   103  
   104  ## QUOTAS
   105  
   106  `podman volume create` uses `XFS project quota controls` for controlling the size and the number of inodes of builtin volumes. The directory used to store the volumes must be an `XFS` file system and be mounted with the `pquota` option.
   107  
   108  Example /etc/fstab entry:
   109  ```
   110  /dev/podman/podman-var /var xfs defaults,x-systemd.device-timeout=0,pquota 1 2
   111  ```
   112  
   113  Podman generates project IDs for each builtin volume, but these project IDs need to be unique for the XFS file system. These project IDs by default are generated randomly, with a potential for overlap with other quotas on the same file
   114  system.
   115  
   116  The xfs_quota tool can be used to assign a project ID to the storage driver directory, e.g.:
   117  
   118  ```
   119  echo 100000:/var/lib/containers/storage/overlay >> /etc/projects
   120  echo 200000:/var/lib/containers/storage/volumes >> /etc/projects
   121  echo storage:100000 >> /etc/projid
   122  echo volumes:200000 >> /etc/projid
   123  xfs_quota -x -c 'project -s storage volumes' /<xfs mount point>
   124  ```
   125  
   126  In the example above we are configuring the overlay storage driver for newly
   127  created containers as well as volumes to use project IDs with a **start offset**.
   128  All containers are assigned larger project IDs (e.g. >= 100000).
   129  All volume assigned project IDs larger project IDs starting with 200000.
   130  This prevents xfs_quota management conflicts with containers/storage.
   131  
   132  ## MOUNT EXAMPLES
   133  
   134  `podman volume create` allows the `type`, `device`, and `o` options to be passed to `mount(8)` when using the `local` driver.
   135  
   136  ## [s3fs-fuse](https://github.com/s3fs-fuse/s3fs-fuse)
   137  
   138  [s3fs-fuse](https://github.com/s3fs-fuse/s3fs-fuse) or just `s3fs`, is a [fuse](https://github.com/libfuse/libfuse) filesystem that allows s3 prefixes to be mounted as filesystem mounts.
   139  
   140  **Installing:**
   141  ```shell
   142  $ doas dnf install s3fs-fuse
   143  ```
   144  
   145  **Simple usage:**
   146  ```shell
   147  $ s3fs --help
   148  $ s3fs -o use_xattr,endpoint=aq-central-1 bucket:/prefix /mnt
   149  ```
   150  
   151  **Equivalent through `mount(8)`**
   152  ```shell
   153  $ mount -t fuse.s3fs -o use_xattr,endpoint=aq-central-1 bucket:/prefix /mnt
   154  ```
   155  
   156  **Equivalent through `podman volume create`**
   157  ```shell
   158  $ podman volume create s3fs-fuse-volume -o type=fuse.s3fs -o device=bucket:/prefix -o o=use_xattr,endpoint=aq-central-1
   159  ```
   160  
   161  **The volume can then be mounted in a container with**
   162  ```shell
   163  $ podman run -v s3fs-fuse-volume:/s3:z --rm -it fedora:latest
   164  ```
   165  
   166  Please see the available [options](https://github.com/s3fs-fuse/s3fs-fuse/wiki/Fuse-Over-Amazon#options) on their wiki.
   167  
   168  ### Using with other container users
   169  
   170  The above example works because the volume is mounted as the host user and inside the container `root` is mapped to the user in the host.
   171  
   172  If the mount is accessed by a different user inside the container, a "Permission denied" error will be raised.
   173  
   174  ```shell
   175  $ podman run --user bin:bin -v s3fs-fuse-volume:/s3:z,U --rm -it fedora:latest
   176  $ ls /s3
   177  # ls: /s3: Permission denied
   178  ```
   179  
   180  In FUSE-land, mounts are protected for the user who mounted them; specify the `allow_other` mount option if other users need access.
   181  > Note: This will remove the normal fuse [security measures](https://github.com/libfuse/libfuse/wiki/FAQ#why-dont-other-users-have-access-to-the-mounted-filesystem) on the mount point, after which, the normal filesystem permissions will have to protect it
   182  
   183  ```shell
   184  $ podman volume create s3fs-fuse-other-volume -o type=fuse.s3fs -o device=bucket:/prefix -o o=allow_other,use_xattr,endpoint=aq-central-1
   185  $ podman run --user bin:bin -v s3fs-fuse-volume:/s3:z,U --rm -it fedora:latest
   186  $ ls /s3
   187  ```
   188  
   189  ### The Prefix must exist
   190  
   191  `s3fs` will fail to mount if the prefix does not exist in the bucket.
   192  
   193  Create a s3-directory by putting an empty object at the desired `prefix/` key
   194  ```shell
   195  $ aws s3api put-object --bucket bucket --key prefix/
   196  ```
   197  
   198  If performance is the priority, please check out the more performant [goofys](https://github.com/kahing/goofys).
   199  
   200  > FUSE filesystems exist for [Google Cloud Storage](https://github.com/GoogleCloudPlatform/gcsfuse) and [Azure Blob Storage](https://github.com/Azure/azure-storage-fuse)
   201  
   202  
   203  ## SEE ALSO
   204  **[podman(1)](podman.1.md)**, **[containers.conf(5)](https://github.com/containers/common/blob/main/docs/containers.conf.5.md)**, **[podman-volume(1)](podman-volume.1.md)**, **mount(8)**, **xfs_quota(8)**, **xfs_quota(8)**, **projects(5)**, **projid(5)**
   205  
   206  ## HISTORY
   207  January 2020, updated with information on volume plugins by Matthew Heon <mheon@redhat.com>
   208  November 2018, Originally compiled by Urvashi Mohnani <umohnani@redhat.com>