Back in November, we wrote Rootless Podman on NFS, which explained why you cannot use the default setup of Podman when running with an NFS home directory. Since then, we have made it easier with newer versions of Podman and have discovered some issues with users setting up these environments.

Currently, rootless Podman (by default) stores its container image content in the user’s home directory. The blog linked above explains that Podman is blocked from using multiple UIDs on the NFS server side since the NFS server does not understand user namespace. The blog recommends that the user set up a different directory for storing content. Users need to edit the storage.conf file to make that happen.

About rootless_storage_path

We have added a new option field to storage.conf named rootless_storage_path to make it easier to use rootless Podman on an NFS home directory for different users.

$ man containers-storage.conf

       rootless_storage_path="$HOME/.local/share/containers/storage"

       Storage path for rootless users. By default, the graphroot for rootless users is set to $XDG_DATA_HOME/containers/storage, if XDG_DATA_HOME is set. Otherwise, $HOME/.local/share/containers/storage is used. This field can be used if administrators need to change the storage location for all users.

              The rootless storage path supports three substations:
              * `$HOME` => Replaced by the users home directory.
              * `$UID`  => Replaced by the users UID
              * `$USER` => Replaced by the users name

A common use case for this field is to provide a local storage directory when user home directories are NFS-mounted (podman does not support container storage over NFS).

This feature lets an administrator set up a machine with NFS home directories point the user’s container content to a separate directory.

For example, see the following setting:

rootless_storage_path="$/var/lib/user/$USER/containers/storage"

If the user sally executed Podman as a normal user, Podman would attempt to create the directories /var/lib/user/sally/containers/storage, and store the container images in that directory. It would also use these directories for all other containers. If ralph logged into the same machine and executed Podman, his storage would be /var/lib/user/ralph/containers/storage. Obviously, these directories would need to pre-exist and be writable by the respective user. The administrator could set up the parent directories, /var/lib/users, to be world-writable, and the Podman command would create the entire path.

Now, this leads me to my second point for this blog.

Using tmp directories for container storage

Administrators may be tempted to use /tmp or /var/tmp as container storage directories. Well, some of our users have reported problems when using these directories. The users reported that random files/directories disappeared from their images and containers. We diagnosed the problem and figured out that systemd was doing tmpfile cleanup. Systemd periodically triggers a job to clean up old content left in temporary directories. This job was erasing older files and directories stored in container-storage. The systemd-tmpfiles does not know about these Podman directories - it just does its job.

Wrap up

The bottom line is that if an administrator wants to store his content in /var/tmp or /tmp, they need to modify the systemd-tmpfiles to ignore the container content directories. Finally, on RHEL, CentOS, and Fedora, as well as many other distributions, the /tmp is on a tmpfs, which by default is only allowed to store up to 50% the size of memory, and will be destroyed on reboot.

[ Getting started with containers? Check out this free course: Deploying containerized applications: A technical overview. ]


关于作者

Daniel Walsh has worked in the computer security field for over 30 years. Dan is a Senior Distinguished Engineer at Red Hat. He joined Red Hat in August 2001. Dan leads the Red Hat Container Engineering team since August 2013, but has been working on container technology for several years. 

Dan helped developed sVirt, Secure Virtualization as well as the SELinux Sandbox back in RHEL6 an early desktop container tool. Previously, Dan worked Netect/Bindview's on Vulnerability Assessment Products and at Digital Equipment Corporation working on the Athena Project, AltaVista Firewall/Tunnel (VPN) Products. Dan has a BA in Mathematics from the College of the Holy Cross and a MS in Computer Science from Worcester Polytechnic Institute.

I am an engineer in the containers engine team at Red Hat. I have a passion for container-related projects, where I started my career, and contribute to projects like Podman and Skopeo.

UI_Icon-Red_Hat-Close-A-Black-RGB

按频道浏览

automation icon

自动化

有关技术、团队和环境 IT 自动化的最新信息

AI icon

人工智能

平台更新使客户可以在任何地方运行人工智能工作负载

open hybrid cloud icon

开放混合云

了解我们如何利用混合云构建更灵活的未来

security icon

安全防护

有关我们如何跨环境和技术减少风险的最新信息

edge icon

边缘计算

简化边缘运维的平台更新

Infrastructure icon

基础架构

全球领先企业 Linux 平台的最新动态

application development icon

应用领域

我们针对最严峻的应用挑战的解决方案

Virtualization icon

虚拟化

适用于您的本地或跨云工作负载的企业虚拟化的未来