CentOS 8
Sponsored Link

Podman : Use External Storage (NFS)2019/10/11

 
This is an example to use NFS External Storage.
[1]
NFS server is required to be running on your LAN, 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=nfs \
--opt o=addr=10.0.0.35,rw,nfsvers=4 \
--opt device=:/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": "2021-03-17T22:04:41.34025285-06:00",
        "Labels": {},
        "Scope": "local",
        "Options": {
            "device": ":/home/nfsshare",
            "o": "addr=10.0.0.35,rw,nfsvers=4",
            "type": "nfs"
        }
    }
]

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

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

[root@e21f52c928fa /]#
df -hT /nfsshare

Filesystem      Type  Size  Used Avail Use% Mounted on
:/home/nfsshare nfs4   26G  2.3G   24G   9% /nfsshare

[root@e21f52c928fa /]#
echo "Podman NFS Volume Test" > /nfsshare/testfile.txt

[root@e21f52c928fa /]#
cat /nfsshare/testfile.txt

Podman NFS Volume Test
Matched Content