NAME 名称

podman-volume-create - Create a new volume
podman-volume-create - 创建一个新卷

SYNOPSIS 概要

podman volume create [options] [name]
podman volume create [选项] [名称]

DESCRIPTION 描述

Creates an empty volume and prepares it to be used by containers. The volume can be created with a specific name, if a name is not given a random name is generated. You can add metadata to the volume by using the --label flag and driver options can be set using the --opt flag.
创建一个空卷并准备让容器使用。可以使用特定名称创建卷,如果未提供名称,则会生成随机名称。您可以使用 --label 标志向卷添加元数据,并可以使用 --opt 标志设置驱动程序选项。

OPTIONS 选项

--driver, -d=driver

Specify the volume driver name (default local). There are two drivers supported by Podman itself: local and image.
指定卷驱动程序名称(默认为本地)。Podman 本身支持两种驱动程序:本地和镜像。

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.
本地驱动程序默认使用磁盘上的目录作为后端,但如果指定了 --opt,则还可以使用 mount(8) 命令将文件系统挂载为卷。

The image driver uses an image as the backing store of for the volume. An overlay filesystem is created, which allows changes to the volume to be committed as a new layer on top of the image.
镜像驱动程序使用镜像作为卷的后备存储。创建一个叠加文件系统,允许将卷的更改提交为图像顶部的新层。

Using a value other than local or image, Podman attempts to create the volume using a volume plugin with the given name. Such plugins must be defined in the volume_plugins section of the containers.conf(5) configuration file.
使用除了本地或镜像之外的值,Podman 尝试使用给定名称的卷插件创建卷。这些插件必须在 containers.conf(5) 配置文件的 volume_plugins 部分中定义。

--help --帮助 ¶

Print usage statement 打印使用说明

--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.
如果命名卷已经存在,则不要失败,而是只打印名称。请注意,新选项不会应用于现有卷。

--label, -l=label --label, -l=label

Set metadata for a volume (e.g., --label mykey=value).
为卷设置元数据(例如,--label mykey=value)。

--opt, -o=option --opt,-o=选项

Set driver specific options. For the default driver, local, this allows a volume to be configured to mount a filesystem on the host.
设置特定于驱动程序的选项。对于默认驱动程序 local,这允许配置卷以在主机上挂载文件系统。

For the local driver the following options are supported: type, device, o, and [no]copy.
对于 local 驱动程序,支持以下选项: typedeviceo[no]copy

  • The type option sets the type of the filesystem to be mounted, and is equivalent to the -t flag to mount(8).
    type 选项设置要挂载的文件系统的类型,并等效于 mount(8) 命令的 -t 标志。

  • The device option sets the device to be mounted, and is equivalent to the device argument to mount(8).
    device 选项设置要挂载的设备,并等效于 mount(8) 命令的 device 参数。

  • 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.
    copy 选项启用从创建挂载的容器镜像路径到首次运行时新创建的卷的文件复制。 copy 是默认值。

The o option sets options for the mount, and is equivalent to the filesystem options (also -o) passed to mount(8) with the following exceptions:
o 选项设置挂载的选项,相当于传递给 mount(8) 的文件系统选项(也是 -o ),但有以下例外:

  • 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).
    o 选项支持 uidgid 选项,用于设置创建的卷的 UID 和 GID,这些选项通常不受 mount(8) 支持。

  • 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. The size option is supported on the “tmpfs” and “xfs[note]” file systems. The inodes option is supported on the “xfs[note]” file systems. 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.
    o 选项支持 size 选项,用于设置创建的卷的最大大小, inodes 选项用于设置卷的最大 inode 数,以及 noquota 用于完全禁用配额支持,即使用于跟踪磁盘使用情况。 size 选项支持“tmpfs” 和 “xfs[note]” 文件系统。 inodes 选项支持“xfs[note]” 文件系统。注意:xfs 文件系统必须使用 xfs_quota(8) 手册中描述的 prjquota 标志挂载。如果没有挂载,Podman 将抛出错误。

  • The o option supports using volume options other than the UID/GID options with the local driver and requires root privileges.
    o 选项支持在本地驱动程序中使用除 UID/GID 选项之外的卷选项,并需要 root 权限。

  • 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.
    o 选项支持 timeout 选项,允许用户在卷创建失败之前设置驱动程序特定的超时时间(以秒为单位)。例如,--opt=o=timeout=10 设置驱动程序超时时间为 10 秒。

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.
请注意,不要将 --opt,-o 创建选项与 -o 挂载选项混淆。例如,在 podman volume create 中,请使用 -o=o=uid=1000 而不是 -o=uid=1000

For the image driver, the only supported option is image, which specifies the image the volume is based on. This option is mandatory when using the image driver.
对于镜像驱动程序,唯一支持的选项是 image ,它指定了卷所基于的镜像。在使用镜像驱动程序时,此选项是强制的。

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.
当不使用本地和镜像驱动程序时,给定的选项将直接传递给卷插件。在这种情况下,支持的选项由相关插件而不是 Podman 决定。

EXAMPLES 示例

Create empty volume. 创建空卷。

$ podman volume create

Create empty named volume.
创建空命名卷。

$ podman volume create myvol

Create empty named volume with specified label.
创建具有指定标签的空命名卷。

$ podman volume create --label foo=bar myvol

Create tmpfs named volume with specified size and mount options.
创建具有指定大小和挂载选项的 tmpfs 命名卷。

# podman volume create --opt device=tmpfs --opt type=tmpfs --opt o=size=2M,nodev,noexec myvol

Create tmpfs named volume testvol with specified options.
使用指定选项创建名为 testvol 的 tmpfs 卷。

# podman volume create --opt device=tmpfs --opt type=tmpfs --opt o=uid=1000,gid=1000 testvol

Create image named volume using the specified local image in containers/storage.
在 containers/storage 中使用指定的本地镜像创建镜像卷。

# podman volume create --driver image --opt image=fedora:latest fedoraVol

QUOTAS 配额 ¶

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.
podman volume create 使用 XFS project quota controls 来控制内置卷的大小和索引节点数量。用于存储卷的目录必须是 XFS 文件系统,并使用 pquota 选项挂载。

Example /etc/fstab entry:
示例 /etc/fstab 条目:

/dev/podman/podman-var /var xfs defaults,x-systemd.device-timeout=0,pquota 1 2

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 system.
Podman 为每个内置卷生成项目 ID,但这些项目 ID 需在 XFS 文件系统中保持唯一。这些项目 ID 默认情况下是随机生成的,有可能与同一文件系统上的其他配额重叠。

The xfs_quota tool can be used to assign a project ID to the storage driver directory, e.g.:
xfs_quota 工具可用于为存储驱动目录分配项目 ID,例如:

echo 100000:/var/lib/containers/storage/overlay >> /etc/projects
echo 200000:/var/lib/containers/storage/volumes >> /etc/projects
echo storage:100000 >> /etc/projid
echo volumes:200000 >> /etc/projid
xfs_quota -x -c 'project -s storage volumes' /<xfs mount point>

In the example above we are configuring the overlay storage driver for newly created containers as well as volumes to use project IDs with a start offset. All containers are assigned larger project IDs (e.g. >= 100000). All volume assigned project IDs larger project IDs starting with 200000. This prevents xfs_quota management conflicts with containers/storage.
在上面的示例中,我们正在配置覆盖存储驱动程序,以便为新创建的容器和卷使用具有起始偏移量的项目 ID。所有容器被分配较大的项目 ID(例如 >= 100000)。所有卷分配的项目 ID 大于等于 200000 的项目 ID。这可以防止 xfs_quota 与容器/存储的管理冲突。

MOUNT EXAMPLES 挂载示例

podman volume create allows the type, device, and o options to be passed to mount(8) when using the local driver.
podman volume create 允许在使用 local 驱动程序时传递 typedeviceo 选项。

s3fs-fuse

s3fs-fuse or just s3fs, is a fuse filesystem that allows s3 prefixes to be mounted as filesystem mounts.
s3fs-fuse 或者只是 s3fs ,是一个 fuse 文件系统,允许将 s3 前缀挂载为文件系统挂载点。

Installing: 安装中:

$ doas dnf install s3fs-fuse

Simple usage: 简单使用:

$ s3fs --help
$ s3fs -o use_xattr,endpoint=aq-central-1 bucket:/prefix /mnt

Equivalent through mount(8) 通过 mount(8) 等效:

$ mount -t fuse.s3fs -o use_xattr,endpoint=aq-central-1 bucket:/prefix /mnt

Equivalent through podman volume create 通过 podman volume create 等效

$ podman volume create s3fs-fuse-volume -o type=fuse.s3fs -o device=bucket:/prefix -o o=use_xattr,endpoint=aq-central-1

The volume can then be mounted in a container with
然后可以将卷挂载到容器中

$ podman run -v s3fs-fuse-volume:/s3:z --rm -it fedora:latest

Please see the available options on their wiki.
请查看他们维基上提供的选项。

Using with other container users
与其他容器用户一起使用 ¶

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.
上面的示例之所以有效,是因为卷被挂载为主机用户,并且在容器内 root 被映射到主机中的用户。

If the mount is accessed by a different user inside the container, a “Permission denied” error will be raised.
如果容器内的不同用户访问挂载点,则会引发“权限被拒绝”错误。

$ podman run --user bin:bin -v s3fs-fuse-volume:/s3:z,U --rm -it fedora:latest
$ ls /s3
# ls: /s3: Permission denied

In FUSE-land, mounts are protected for the user who mounted them; specify the allow_other mount option if other users need access.
在 FUSE 领域,挂载对于挂载它们的用户是受保护的;如果其他用户需要访问,请指定 allow_other 挂载选项。

Note: This will remove the normal fuse security measures on the mount point, after which, the normal filesystem permissions will have to protect it
注意:这将移除挂载点上的正常 FUSE 安全措施,之后,正常的文件系统权限将必须保护它。

$ 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
$ podman run --user bin:bin -v s3fs-fuse-volume:/s3:z,U --rm -it fedora:latest
$ ls /s3

The Prefix must exist
前缀必须存在。

s3fs will fail to mount if the prefix does not exist in the bucket.
如果存储桶中不存在前缀, s3fs 将无法挂载。

Create a s3-directory by putting an empty object at the desired prefix/ key
通过在所需的 prefix/ 键处放置一个空对象来创建 s3 目录。

$ aws s3api put-object --bucket bucket --key prefix/

If performance is the priority, please check out the more performant goofys.
如果性能是首要考虑因素,请查看性能更高的 goofys。

FUSE filesystems exist for Google Cloud Storage and Azure Blob Storage
为 Google Cloud Storage 和 Azure Blob Storage 存在 FUSE 文件系统

SEE ALSO 参见 ¶

podman(1), containers.conf(5), podman-volume(1), mount(8), xfs_quota(8), xfs_quota(8), projects(5), projid(5)

HISTORY 历史 ¶

January 2020, updated with information on volume plugins by Matthew Heon mheon@redhat.com November 2018, Originally compiled by Urvashi Mohnani umohnani@redhat.com
2020 年 1 月,由 Matthew Heon mheon@redhat.com 更新了有关卷插件的信息,2018 年 11 月,最初由 Urvashi Mohnani umohnani@redhat.com 编译