How to manage storage with Podman volumes
Podman(Pod Manager) is the Daemonless, Open Source, Linux Native utility to create, manage, and run OCI(Open Container Initiative) containers and pods. Podman is a great Docker container alternative when you need greater security, UID separation via namespaces, and system integration. Podman is excellent for development, testing in CI/CD pipelines, and microservices, with very capable image management tools, and also systemd integration for service management.
Table of Content
What are Podman volume?
Podman Volume is the set of subcommands that manage volumes. Podman creates and manages volumes. A volume is a section in the host filesystem attached to a running container, which means data from one place gets copied over to another place persists, and is shared between containers. It can be built manually with the podman volume command or during container construction.
Step-by-Step Guide To Manage Storage with Podman Volumes
Step 1: List Existing Volumes
You may use the following command to verify existing volumes before establishing new ones.
podman volume ls
Output:

Step 2: Make a New Volume
Use the podman volume create command to start a new volume.
podman volume create mydata
Output:

Step 3: List all created volume
When storing data which needs to remain intact between container restarts or re-creations, volumes come in useful.
podman volume ls
Output:

Step 4: Inspect a Volume
After creating a volume, you may check it to get information about it, including the mount point and options.
podman volume inspect mydata
Output:

Step 5: Mount Host Directory as a Volume
In the next step, you will create a container and mount a host directory as a volume with Podman.
podman run -d --name webapp -v /var/www/html:/usr/share/nginx/html:Z nginx
Output:

Step 6: Check Mounted Volumes in a Running Container
Use the following command to verify volumes mounted in a running container
podman inspect --format "{{ .Mounts }}" <container_name>
Output:

Step 7: Unmount a Volume
Then, you can stop the container and unmount a volume from it without taking the container or the volume out.
podman stop <container_name>
Output:

Step 8: Clean Up Unused Volumes
Remove any volumes that are not in use by any containers.
podman volume prune
Output:

Best Practices of Manage Storage with Podman Volumes
- Keep Data Backups Regular: Copy volumes containing important data regularly, mounting them in a temporary container by making a copy of the contents.
- Volume Disk Usage Monitoring: Monitor on your volumes' disk utilization to avoid stressing the host's storage infrastructure. No space and issues with the system working.
- Clean Unused Volumes: Regular storage cleanups involve running a podman volume prune to remove any unrequired or orphaned volumes. This prevents clutter from unused volumes and frees up disk space.
- Use Volumes for Persistent Storage: There is no need to keep application data inside the layers of a container. One should store application data directly within volumes. A person should use a volume if one needs to keep logs, database files, and other important data.
People also Read
Conclusion
In conclusion, Working with containerized systems requires knowing how to manage storage using Podman volumes, particularly when handling persistent data. Podman volumes offer a straightforward yet effective method for storing data throughout the lifecycles of containers, making container management more reliable and adaptable.