Fedora 31
Sponsored Link

Podman : Use External Storage
2019/11/19
 
When Container is removed, data in it are also lost, so it's necessary to use external storage on Container if you need.
[1] It's possible to mount a directory on Container Host into Containers as a external storage.
# create a directory

[root@dlp ~]#
mkdir -p /var/lib/containers/disk01

# run container with mounting the directory on /mnt

# if SELinux is [Enforcing], needs [--privileged] option like follows

[root@dlp ~]#
podman run --privileged -it -v /var/lib/containers/disk01:/mnt fedora /bin/bash
[root@0a8d0b4cc434 /]#
df -hT

Filesystem              Type     Size  Used Avail Use% Mounted on
overlay                 overlay   73G  4.0G   70G   6% /
tmpfs                   tmpfs     64M     0   64M   0% /dev
/dev/mapper/fedora-root xfs       73G  4.0G   70G   6% /mnt
shm                     tmpfs     63M     0   63M   0% /dev/shm
tmpfs                   tmpfs    5.9G  1.2M  5.9G   1% /etc/hosts

[root@0a8d0b4cc434 /]#
echo "persistent storage" >> /mnt/testfile.txt

[root@0a8d0b4cc434 /]#
exit
[root@dlp ~]#
cat /var/lib/containers/disk01/testfile.txt

persistent storage
Matched Content