RHCSA RHEL 8 - Containers - Getting Started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi and welcome to yet another video in the rhcsa video series today's video is on containers getting started so we're going to talk a bit about what containers are and then we're going to do some basic management of containers i'm using an application called podman which is essentially for managing pods but pods are like multiple containers so it's just a matter of managing those so the idea is that a container is a extrapolated operating system so you've got the os at another layer so you have um the os running across in the back end basically so you have a common os be it red hat whatever and then you have the container on top of that so say if you want a httpd server you wouldn't build a new red hat server you wouldn't then install httpd then configure it and all that sort of stuff you can have pre-canned images that have all this pre-confined uh pre-configured so you'd use a container so you'd use something like pod man or in in most common cases people use things like docker and docker has adoka and podman have lots of images um that allow us to say i don't know i want to spin up a http instance the instance i'll pull that image down and i will run it as a container on my system so we'll do is it will run it as a in the background as a container and that would actually function as a full httpd server and it utilizes your backend operating system to actually run it so you could have you could have obviously multiple different types of containers but um a common thing we see is we have like these um fairly beefy systems that run these run docker or podman pretty much the same thing really and they allow us to then um run multiple containers on that same system so we could have i don't know 10 instances of httpd running and say if we lose one of those crashes for whatever reason we've then got um another nine just that can keep continue going and also with all the orchestration within containerization you can also say one particular node is crashed so let's delete that node or container and let's spin up a brand new one and you can do that almost you can do that completely on the fly without any human interaction so it means that you've you're a lot more highly available in that way as well another benefit is potentially with security as well because you could standardize your container and give it just only the access it requires so perhaps it just it's a http server so it needs port 80 and 443 access in it and you can actually shut completely shut down ssh to that to the container so the whole of the http base can be completely locked down and the only way to access it is you create a new image or a new container which a new image for the container which you then spin up to make new the new of the changes within that container so say um either httpd has been updated and you want to update it so you update it in the offline image you've got of it you create all the do all the little changes um make it save the image then pull that image down into your docker repository and then replace one by one your current containers with this new uh new image and it obviously creates new containers i hope that makes sense so um yeah i'll try to put some graphics on the screen as well that kind of explain it but i'll also link in the description for some more details if there was a if that was a bit unclear in that in that particular section so what we would do um is we now will run through some stuff around podman and i guess it also make more sense as as we're going along um exactly what we'd i can kind of explain as we go along what we're doing and how it's all working so kind of it kind of uh explains itself better when we do that so the first thing we'll be to do is uh install podman in most cases that won't be installed already so we're just gonna do it as always just do a pseudo bash [Music] so people that have used docker before will actually find that podman pretty much has the same cli so that's a there's certainly a benefit for a lot of people that um have i've played with docker before uh certainly i have um so that kind of helped me pick up podman wrap it pretty rapidly to be honest um it's all pretty much the same thing it's uh nothing major in there thankfully so let's let it do its installation stuff so yeah in just cases you missed that as well so it's just uh dnf install pod man and it installs quite a few um packages okay so that's installed so we've done so far is installed pod man so podman has a pretty comprehensive help i think you just do podman help and it will list almost pretty much all the commands are available here um but we'll we'll go through some of these of course not all of these are going to be immediately relevant um because there's a lot of um you can go pretty complex with containers as you can imagine so let's do first thing to do is let's do a pod man search and let's search for http so there's a good example as one mentioned previously so podman search httpd okay so that's not that's displaying pretty badly but um okay so if i go back up to top it kind of make it a bit more clear so we've got index name description which is this stars so stars is how many people have personally liked it is it official and is there any automation there so so let's go here and have a look look for something other than zero there's no stars on a lot of these so they're probably not the greatest ones there's actually one here look um and it's from the docker library so it's probably a good shot uh it's just a http apache http server project so i think that looks like a pretty good one this one's got quite a high number as well um it's only got nine and stuff but this is uh three thousand nine hundred and three thousand one hundred and ninety one so it's probably the best one so we pulled the full name here so docker.io is the um the library is coming from or index um so just ignore that price the second part we need so it's just this name here so docker io slash library slash httpd so just copy that and i'll just do a clear to bring this up to the top just do a pod man pull to pull it down i'm going to give it the full name and press enter and you can see it's copying all the relevant files and pretty much that's it done so it's as quick as that so we now have everything we require to create a very very basic httpd instance so let's if we do pod man images we can see on the repository this one which we just did got to tag the latest at the moment with the image id is currently this when it last created so it's quite up to date and the size of the image so obviously new images will be created as i mentioned earlier and then we would have to incorporate those in our um into our containers once we are happy they're working [Music] right so how do we actually run a container so we just do is actually podman run [Music] and we can just give it the name of the repository so if you noticed um i'm getting lots of messages directly uh into the log so what it's doing is running directly into the command line so this is um in an attached mode which is um what you don't really want in most cases to be honest and so it's running the container directly on the system and that is could taking away your prompt so i can do is terminate this so we just do pod man um we'll do postman ps so there's no current currently containers running so ps is uh processes so we just do clear again so we'll do another podman run okay this time we're going to do minus d and then t to give us a terminal if we need to go into it um but we will so minus d is for detached minus t for the terminal or um yeah tty and let's do some portfolio in so minus p 8080 to 80 tcp so what's happening here is if someone connects on port 80 to our system is that 8080 on the system is going to redirect it to port 80. so it allows us it allows us to do some network address translation so again if you're running multiple um different http servers and different services on the same system you may have different ports going to different things that sort of thing so um you can do it this way so we'll just do this and then we'll give it the name so we're going to run it with detach mode and we have a terminal if we need it minus p to do the portfolio 8082 480 tcp and we get all this number here so it's basically the pod that's like this the um container id that's running so if we just do a pod man [Music] ps we now have a container so do ps minus a we get a bit more information so again you see the ones that have actually been killed off earlier so you can see that's my original one so this one ps will just show us what's currently running and then ps minus a will show us the stuff that's also been exited so we've got some exited ones here so we can see there's been update up 19 seconds so if i rerun that ps command it's been up for 45 seconds now so let's test this out so if we do a podman ps again just make sure it's running it looks very happy so if we connect on basically localhost port 8080 we should be able to get to it so you can try from this machine here local on the machine okay so in my firefox window i'm just going to type 127.0.0.1 and then 8080 and we've got it works message so that's a very very good sign that that's working um we can actually confirm that really is what we're seeing here so we flick back to the terminal and we can just do a pod man and then stop and to specify which one we want to stop we actually can just give the name so it's a short name here but we've also got the long name you can actually specify the long name as well so that was when we first run it we'll give that full name there and we'll just give that the short name here so give a few seconds it's now stopped let's just do podman ps we now have nothing ready just flick back refresh the page and unable to connect so that was definitely running from that pod so cool let's do that again let's rerun that again so we can have 8082 so i'm doing now is just repeating the command for different ports and now if we do a podman ps you now see we have a lot of containers and i've given different ports because obviously they have to be different as you can see in here that message there this is saying you cannot burn to the test address already in use which makes sense because you can't port forward to something that's already um using that port so so if i do refresh this now that should work i also actually had to go to 8081 8082 883 four oh four i didn't think i did did i hopefully it didn't or versus broken yeah 883 is the last one i did so that's all good okay so if i clear the screen now we can also do a podman logs so if i do podman ps let's get the name container id first and we can just do a podman locks [Music] so it is all the logs from this so podman logs and we can see i couldn't determine the follow qualified domain name that's fine because that is because i don't have dns in this particular environment that's absolutely fine um resume normal operations for um apache no worries and we've got the command line is has been run this is just command line for apache and we can see the gets so that's actually us getting the um you can also use these um random names it generates so some people may use those to um to reference the pods the uh containers so if we do a you can do the same thing with that so there's just a random name it creates so busy heisenberg just brings me back to uh breaking bad perhaps not so much pods but that's great so let's do a podman top so top um as i covered in previous videos is the processes so we can have a look at what's running um on there so you can see not much and also very very very light and there's not really that much running on the system at all so it's it's good to see it's very light and efficient and as you can see we can just kill one off and bring it back up so if something was broken in that port 8081 i could stop it then start a new one up and and we're good so we can do it let's see if we do a pod man stop and do busy heisenberg so we can do that so we can do a start and stop so potentially you could have um we're going to cover that in the future where we have that start and stop as part of um service scheduling so system ctl will start and stop that as part of the system so you could have that again you could have a docker or sorry a pod podman run as part of the system startup so you could have a httpd startup as part of this for example so start and stop just literally starts and stops the pod so if you do let's just stop again and just do a podman ps you can see there's only three running now if we do a ps minus a we can see it was exited eight seconds ago so it's the one i just exited let's just do a pod man start again and for example we really want to get rid of this particular container and we want to delete it so let's do a pod man remove and give its name again ah it's running so that's a good point yeah it should stop that the podman stop two minutes to stop and start so i forgot which one number one um problem and stop and then we do polygon rm so that's been removed and if we do a podman ps we can see that we've only got those free running pod man ps minus a so if we do a podman ps minus a after removing that we can now see the one that is running on 8082 which is the heisenberg entry has been completely removed so that's all cleaned up and removed from our ps minus a that's pretty much all i want to cover within the podman section uh they again this has a manual page and it's just a container engine yep cli comparable yes basically easy to transition between the two um i'm gonna do more advanced features as we uh progress through these this mini course um as part of the it's gonna be covered in the rhcsa as of um first of october so basically right now it's going to be an exam so make sure you cover this if you haven't already um yeah i hope this uh is doing info on podman as well so yeah a bit more info as well on the command so that's pretty much it thanks for viewing my video as always can you click hit the like button if you've enjoyed this video hit subscribe if you haven't already hit the bell icon for notifications of when i do release new videos as you've noticed already i've popped on the screen the usual stuff so i've got the kofi page for any donations if you are kind enough to donate to me that would be awesome um also i've popped my tea public page for any merchandise if that's your thing you're interested in and finally my discord server url information and you can use that um to ask more detailed questions if you can't ask on youtube itself so you're more than welcome to check it out thank you
Info
Channel: Computers, Security & Gadgets
Views: 12,998
Rating: 4.9498434 out of 5
Keywords: rhsca, rhcsa, red, hat, red hat, red hat certified, red hat certified system administrator, rhel 8, rhel, linux, redhat8, redhat 8, red hat 8, system, admin, administrator, redhat, networking, systems, red hat8, red-hat, rhel8, containers, docker, podman, learning
Id: KXbxoCVV6OQ
Channel Id: undefined
Length: 20min 7sec (1207 seconds)
Published: Sat Oct 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.