Image: fatmawati/Adobe Stock For anyone who’s made the switch from a Ubuntu-based to an RHEL-based Linux circulation for container implementations, you’ve most likely recognized that Docker isn’t the easiest or best choice for your brand-new platform. Fortunately, Podman is set up by default on the majority of RHEL-based circulations, so you can avoid straight to working with your containers.
But why would you wish to find out an entirely brand-new tool? Fortunately, Podman is almost a direct 1:1 replacement for Docker, so if you know one you can utilize the other. I have actually currently assisted you take your primary steps with Podman and this time around we’re going to extend that a bit by creating and handling volumes.
Why are volumes crucial? Simple– relentless storage. Say, for instance, you deploy a container that utilizes data. Whatever is going terrific until disaster strikes. The container fails and takes your information down with it. You do not desire that.
SEE: Hiring kit: Back-end Developer (TechRepublic Premium)
To prevent such a disaster, you ‘d release those containers using volumes. By doing this, the information is saved to a consistent state, so if the container goes down, the information is still safe and can be utilized by a various container. Trust me, you want to utilize volumes for any container that will depend upon data. This is especially so if you or your company depends on the information utilized by that container.
With that stated, how do you deal with volumes in Podman? Let’s find out.
What you’ll require to develop and handle volumes with Podman
The only thing you’ll need for this is a Linux circulation with Podman set up. This could be RHEL, Rocky Linux, AlmaLinux, or CentOS. That’s it.
How to develop a volume with Podman
The first thing we require to do is produce a volume. Visit to your Linux distribution and open a terminal window. Let’s state we’re going to produce a volume for an NGINX container. Produce that volume with:
podman volume produce nginx-volume
The output should be easy:
nginx-volume
You can confirm the volume production with the command:
podman volume ls
The above command ought to print out something like this:
DRIVER VOLUME NAME regional nginx-volume
To get more information, you could issue the command:
podman volume inspect nginx-volume
The above command will print out something like this:
[containers] How to utilize a volume with Podman
Now that we’ve created the volume, let’s use it with an NGINX container deployment. Prior to we do, let’s have some enjoyable and develop a new index.html apply for the NGINX web server. Modification into the volume directory site with the command:
cd/ house/$USER/. local/share/containers/ storage/volumes/nginx-volume/ _ data
Now, let’s develop our index.html with:
nano index.html
In that file, paste the following:
Hello, TechRepublic!
Save and close the file.
Deploy the container attached to the volume with the command:
podman run -d -p 8080:80 -v nginx-volume:/ usr/share/nginx/ html– name nginx-volumetest nginx: latest
What we’ve done with the above command is mapped our nginx-volume to the/ usr/share/nginx/ html directory within the NGINX container. Now, if we point a web browser to http://IP:8080, where IP is the IP address of the hosting server, we must see our “Hello, TechRepublic!” message.
If you see an error, you’ll require to open the firewall with the following 2 commands:
sudo firewall-cmd– long-term– add-port 8080/tcp sudo firewall-cmd– reload
Now, if you refill the web page, you’ll see the message (Figure A).
Figure A
Our” Hello, TechRepublic!” message is displayed. Now, should your container stop working, the data in the volume will stay undamaged. If you ever require to erase the volume, you could simply provide the command:
podman volume rm nginx-volume
Which’s all there is to handling volumes with Podman. This is an essential function for anyone looking to keep persistent information for their container deployments.
Subscribe to TechRepublic’s How To Make Tech Deal With YouTube for all the most recent tech advice for organization pros from Jack Wallen.