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:

<h2>Hello, TechRepublic!</h2>

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 http://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.