Attaching Persistent Storage to a Container
Start course
1h 46m

This course covers a range of techniques to help you run your own containerized applications using Red Hat. Throughout this course, you will follow along with guided presentations from the Red Hat platform to get a first-hand understanding of how to run containers and manage your workflows using Red Hat.

Learning Objectives

  • Learn the basics of setting up web servers and containers
  • Understand how to find and manage containers
  • Understand how to perform advanced container management
  • Learn how to attach persistent storage to a container
  • Learn how to manage containers as services

Intended Audience

This course is ideal for anyone who wants to learn how to run containers with Red Hat.


To get the most out of this course, you should have a basic understanding of Red Hat and of how containers work.



As promised, right now we are going to have a look at Attaching Persistent Storage to a Container and we know that in order for you to get a container running you need an image because inside of an image you would have the files that are going to be deployed into your running container. So, let's go and take this to the whiteboard. Here we have an image, there are files inside of that image. The files inside of the image are going to be deployed into our running container. That image also has metadata associated with it. So, it would also amongst other things specify those processes that are going to be started whenever the container starts from that particular image and of course your container runs on a container host.

Now one thing you have to be mindful of is that when you make changes to a running container those changes are temporary, they're ephemeral because containers make use of ephemeral storage.

If you want something to be changed permanently what you ought to do is make the change to the image but what about database processes? We can't bake database related data into a container image, we want to keep this dynamic. So, what we are now want to talk about is how you can get storage made available into your container. So, let's just say that your host has some storage. So, guys this could be a directory. So, here we have some storage on your host, what we want to do right now is make that storage make that directory available inside of a running container and this is made possible with the v option which is to do a volume mount, from the container host to the running container.

So, for example let's just say that we have a directory on the container host, it doesn't matter what that directory is. If we wanted to make it available inside of the container at /var/lib/mysql. This is accomplished using the podman run command with the v option. So, what we would do is that we would specify the directory on the container host colon and then we would specify the destination mount point inside of the running container. Now there is a consideration and that consideration is SELinux and the directory that you are wanting to mount or to have the SELinux type context of container-file-t. So, guys I am really itching to demonstrate this to you. We are going to be experiencing Attaching Persistent Storage to a Container in the next guided exercise. So, head on over there where I will meet you next.

About the Author
Learning Paths

Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, Azure, GCP), Security, Kubernetes, and Machine Learning.

Jeremy holds professional certifications for AWS, Azure, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).