Thursday, November 27, 2025

 

Podman : Use External Storage (NFS)

 

This is an example to use NFS External Storage.

[1]

NFS server is required to be running on your local network, refer to here.
On this example, configure [/home/nfsshare] directory on [nfs.srv.world] as a shared directory.

[2]Create a volume for NFS and use it.
# create [nfs-volume] volume

root@dlp:~# podman volume create \
--opt type=nfs4 \
--opt o=rw \
--opt device=10.0.0.35:/home/nfsshare nfs-volume 
nfs-volume

# display volume list

root@dlp:~# 
podman volume ls

DRIVER      VOLUME NAME
local       nfs-volume

# display details of [nfs-volume]

root@dlp:~# 
podman volume inspect nfs-volume

[
     {
          "Name": "nfs-volume",
          "Driver": "local",
          "Mountpoint": "/var/lib/containers/storage/volumes/nfs-volume/_data",
          "CreatedAt": "2025-08-22T09:38:56.374820193+09:00",
          "Labels": {},
          "Scope": "local",
          "Options": {
               "device": "10.0.0.35:/home/nfsshare",
               "o": "rw",
               "type": "nfs4"
          },
          "MountCount": 0,
          "NeedsCopyUp": true,
          "NeedsChown": true,
          "LockNumber": 12
     }
]

# run container with mounting [nfs-volume] to [/nfsshare] on container

root@dlp:~# 
podman run -it -v nfs-volume:/nfsshare debian
# verify

root@0efc71e368e4:/# 
df -hT /nfsshare

Filesystem               Type  Size  Used Avail Use% Mounted on
10.0.0.35:/home/nfsshare nfs4   27G  945M   25G   4% /nfsshare

root@0efc71e368e4:/# 
echo "Podman NFS Volume Test" > /nfsshare/testfile.txt

root@0efc71e368e4:/# 
cat /nfsshare/testfile.txt

Podman NFS Volume Test

No comments:

Post a Comment