How To Deploy A Podman Container With Persistent Storage
- by Tech Today News
- Posted on April 14, 2023
on
How to deploy a Podman container with persistent storage
If you’re either transitioning to Podman or are new to container development, Jack Wallen shows you how easy it is to deploy a container with persistent storage.
Hello, container developers, Jack Wallen here to help you make tech work. If you’re either transitioning to Podman or are new to container development, I want to show you how easy it is to deploy a container with persistent storage. This is a wonderful way of ensuring your work remains available, even if something goes wrong with the container.
What persistent storage means is that we’re mapping a local drive that will house data to the container drive. I’ll demonstrate with the tried and true NGINX web server. To do this, you’ll need a running instance of Podman on a supported OS like Ubuntu Server or Rocky Linux.
SEE: Check out Jack Wallen’s Podman tutorial on enabling sudo-less container management.
The first thing to do is create a volume that will house the data with the command:
podman volume create nginx-volume
That volume is created in the directory
/home/USER/.local/share/containers/storage/volumes/nginx-volume/_data
, where USER is your Linux username. Next, create a new NGINX index file with the command:
nano /home/USER/.local/share/containers/storage/volumes/nginx-volume/_data/index.html
Where USER is your Linux username. In that file, paste the following content:
Hello, TechRepublic!
Save and close the file. We can now deploy our NGINX container and attach it to the newly created volume that contains our index.html file with the command:
podman run -d -p 8085:80 -v nginx-volume:/usr/share/nginx/html --name nginx-volumetest nginx:latest
Once the container is up and running, you can view the index file by pointing a web browser to SERVER: 8085, where SERVER is the IP address of the hosting server. Make sure to open your firewall to allow port 8085 through, and you’re good to go.
And that’s all there is to deploying an NGINX container with Podman that includes persistent storage.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.
Also See
- How to become a developer: A cheat sheet (TechRepublic)
- Python programming language: This training will jump-start your coding career (TechRepublic Academy)
- 8 must-have tools for developers on Linux (TechRepublic Premium)
- Programming languages and developer career resources (TechRepublic on Flipboard)
- Cloud
- Developer
- Networking
- Open source
- Storage
on April 13, 2023, 3:03 PM EDT How to deploy a Podman container with persistent storage If you’re either transitioning to Podman or are new to container development, Jack Wallen shows you how easy it is to deploy a container with persistent storage. Hello, container developers, Jack Wallen here to help you make tech work.…