FreeBSD 14
Sponsored Link

Podman : Use External Storage (NFS)2024/02/29

 
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]
Podman Host must be an NFS client, refer to here for NFS client settings.
[3] Create a volume for NFS and use it.
# create [nfs-volume] volume

root@dlp:~ # podman volume create \
--opt type=nfs \
--opt o=rw \
--opt device=nfs.srv.world:/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/db/containers/storage/volumes/nfs-volume/_data",
          "CreatedAt": "2024-02-29T09:09:31.749803449+09:00",
          "Labels": {},
          "Scope": "local",
          "Options": {
               "device": "nfs.srv.world:/home/nfsshare",
               "o": "rw",
               "type": "nfs"
          },
          "MountCount": 0,
          "NeedsCopyUp": true,
          "LockNumber": 46
     }
]

root@dlp:~ #
podman images

REPOSITORY                TAG         IMAGE ID      CREATED       SIZE
localhost/freebsd-nginx   latest      a0a053cc78a3  16 hours ago  1.17 GB
localhost/freebsd-httpd   latest      add46dedb2b7  22 hours ago  1.44 GB
localhost/freebsd-base    latest      2527bfa5eeb4  42 hours ago  1.05 GB
quay.io/centos/centos     stream9     ce3ac91d4020  2 weeks ago   161 MB
docker.io/library/ubuntu  latest      3db8720ecbf5  2 weeks ago   80.4 MB

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

root@dlp:~ #
podman run -it -v nfs-volume:/nfsshare freebsd-base /bin/sh
# verify

#
df -hT /nfsshare

Filesystem                                           Type      Size    Used   Avail Capacity  Mounted on
/var/db/containers/storage/volumes/nfs-volume/_data  nullfs     26G    168K     26G     0%    /nfsshare

#
echo "Podman NFS Volume Test" > /nfsshare/testfile.txt

#
cat /nfsshare/testfile.txt

Podman NFS Volume Test
Matched Content