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.
- 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
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.
We have another skills test lined up for you, this time it comes in the form of the Comprehensive Review. So, let's go and get things kick-started from a terminal for the workstation virtual machine. What we are going to be doing is running the command lab rhcsa-compreview4 start.
So, once we have the successes we can proceed. So what we are going to be doing is setting up an HTTP based container, we need to prep it for storage.
So, guys what we're going to do first up is make an ssh connection as the containers user to serverb. From there we are going to elevate our privileges to that of the root user so, we're going to use the sudo -i command. The password for the containers user is redhat. So, next up guys what we are going to do is create a directory that we are going to use to host our web content.
So, the web content has been pre-created for you. So, what we need to do right now is use the mkdir command to create /srv/web. So, from there we are simply going to change into that directory.
So, use the cd command and then like I said we have the content pre-created for you.
So, what we now do is that we are going to use the tar command and we are going to extract the content from a file, that file is in a home/containers/rhcsa-compreview4 and it's web-content.tgz.
So guys, of course if you don't have that file then it could be that the start script didn't execute successfully. So, all we now need to do is make sure that the containers users got access to that /srv/web directory. So, use the command chown -R that's an uppercase R to recursively set the ownership to the containers user and of course we are doing that for /srv/web and you may want to dot your i's and cross your t's, in which case use the ls command to verify the access for /srv/web /srv/web/html/ and then of course we have that content which is /srv/web/html/index.html, serverb doesn't have the container-tools yum module installed. So, from serverb as the root user, use yum module install -y container-tools and again you are not interested in seeing all of that output, so, we are looking for a message that says that this transaction is complete.
So, next what we're going to do is start an apache container. Now in order for us to to use the image that we are told to use. What we need to do is make sure that we are authenticated to registry.lab.example.com. So, from serverb as the containers user what I have done over here is use the command podman login, we are going to authenticate as admin with the password of redhat321 and of course we are authenticating to registry.lab.example.com. So, next up guys what we are told to do right now is to start a container using the httpd-24 image using the tag 1-105. So, the command that we have right now is podman run -d for a detached container, we are going to call it web and we're going to do port forwarding. So, we are going to forward port 8888 on the container host to inside of the container at port 8080 and we are also going to do a volume mount. So, the volume mount that we are doing is from the container host from the directory /srv/web/ and we are going to be forwarding it so or sending that to the container at /var/www. Of course we have to include the colon Z so that we do take care of the SELinux requirement. What we are also told to do is to make an environment variable available, that environment variable is called HTTPD_ MPM with the value of event and then the final argument as you can see over there is the actual name of the of the image that we are going to be using.
So, next up guys what we could do is test that, so just do a curl against localhost port 8888 in which case you should see some sample content. So, you could see that here you can see the heading Comprehensive Review Web Content Test. So, next up what we are going to do is take care of the systemd requirement for containers.
So, as we know what we need to do right now is from the containers user account on serverb we are going to create a directory called .config/systemd/user/. So, once we have created that directory we simply change to it and then from there what we are going to do is use the podman command and we are going to generate the systemd unit files for the container called myweb, of course we're going to store it inside of the the current directory and we want to make sure that we use the - - new option so that the containers are started and stopped correctly.
So, we do have a container running right now, looking at the output of podman ps what we need to do is now put this under the control of systemd. So, let's go and use the podman stop web command.
We are going to remove it as well so, podman rm and now what what we need to do is make sure that systemd is aware of the the unit files that we have just created. So, use the command systemctl - - user and we are going to do a daemon-reload. From there what we're now going to do is make sure that the unit is started and enabled. So, for that we use the command systemctl - -user enable, we are going to start it up right now as well and that's going to be for container-web.service. Now because we don't want that container to only be started whenever the container users user logs in, what we are now going to do is use the loginctl enable-linger command so that the the unit file is managed whenever the system starts and of course when it stops.
So, let's go and check our work. So, what we do right is now that we run the command lab rhcsa- compreview4 grade. As you can see I have got my passes over there I hope that you do too and again if you missed out on any items go back, refactor, regrade. Once you are satisfied go ahead, run the command lab rhcsa-compreview4 finish and with that it brings this Comprehensive Review and the short class to an end. I hope that you guys find value in this and I hope to see you in another class soon.
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).