welcome to this crash course on darker I am Ranga Rao Khurana I have more than 20 years of application development experience with a variety of languages like Java Python JavaScript and a variety of frameworks like REST API frameworks like spring boot print and frameworks like angular react and view I'm also an AW certified solution architect I've been using docker to containerize micro services for a few years now at 28 minutes we ask ourselves one question every day how do we create amazing course experiences the success we had on a wide variety of platforms including udemy with more than 300,000 learners is a result of this pursuit of excellence we believe that learning docker is one of the most important skills for Java developers in this awesome course we'll help you get started with docker by learning all the important basics of docker you'll learn all the important commands as well as you will learn the important concepts around docker containers images repositories registries and a wide variety of other stuff we create docker images for a variety of springboard projects for web applications full stack applications for REST API will also create docker images and run containers for micro services as well we have a couple of micro services called the currency conversion service and the currency exchange service along with it will run containers for Eureka and Zul one of the important takeaways of the course is your learning on docker compose you will learn how to use docker compose to manage your containers we will use docker compose with full stack applications and micro services one of the biggest advantages with docker is the fact that you don't really need to install software on your local machine anymore you'll learn how to use docker hub effectively and we will use images of my sequel ripken RabbitMQ from dhaka hub and create containers for them we expect you to know the basics of Java programming and we expect you to have some experience with spring and spring boot some knowledge of JavaScript and react would be useful when be a container izing the full stack application we will help you to install all the tools that you'd need for this specific course the complete source code including the step-by-step details are available on the github repository of this course what are you waiting for let's have some fun container izing a lot of Springwood applications and learning a lot about docker we had a lot of fun creating this course and we are sure you will have a lot of fun too if you want to learn more go ahead and click the enroll button or you can take a test drive using the free preview feature good luck and I'll see you in the course welcome back let me congratulate you on making a great choice in enrolling for this course in the step let us get quickly started with understanding how you can make the best use of this course the first thing I would recommend you to do is to bookmark the github repository of this course the github repository of this course is github.com slash in 28 minutes slash darker crash course you can also find the link to the github repository in the resources section of the video beginner repository contains the source code for different projects that we will be contain arising during this specific course we will start with container rising rest api we will move on to a web application after that we will have the web application talk to my sequel will containerize that and later we would move to a full stack applications a react front end which is talking to a spring boot API we'll also look at a number of micro services the grip repository also contains a section called getting started in this course we assume that you have some knowledge of spring spring boot JPA hibernate and react however if you don't have that experience you can quickly get started with those frameworks by watching these videos you don't really need to start with watching all these videos right enough what we'll do is when we will get to this specific section where we would use a specific framework we will highlight the videos and articles which might be important for you now let's move on to the installation guide section the installation guide section contains installation instructions for different tools that we would be using during the course the first sections of the course we will be using Java Eclipse and embedded maven so if you don't have Java or Eclipse installed I would recommend you to follow the instructions in this specific video and install those tools any version of Java greater than Java 8 should we find and any of the latest versions of Eclipse should be awesome when we get to the full stack application you can install node.js Visual Studio code fair enough you can skip that part if you have any problems with the installations you also have the troubleshooting instructions down here each of these projects contain a readme file with more details about that specific project we also have a few code backups at different stages of that specific section now I guess I've bought you with a lot of these details the most important thing is bookmark negative repository make sure that you have Java eight or a high version of Java installed make sure that you have the latest version of the Eclipse installed and you are all set I'll see you in the next step until then bye welcome back in the first few steps of this course what we would do is we will install docker and execute a number of docker commands the acha makes the life of a developer as well as somebody from the operations team very easy installing docker and executing a few docker commands gives us a great perspective on what you can achieve with docker once we get that perspective we will talk about what is a virtual machine hub docker is different from a virtual machine and we will talk about the internal architecture of how docker works by the end of the first 30 minutes of the course you should have a great 10000 feet overview of how you can make use of docker to solve your everyday problems now let's get started with installing docker in this specific step a few years back if I told my friends let's come here let's install docker together most of them would actually run away why because installing docker who was not easy boom facing so many problems installing docker that a number of developers don't even want to use docker at all however things have changed for the better in the last few years and today installing docker on most of the operating systems is really a cakewalk it's just a click of few small buttons how can you install docker Google for install docker the first link you should see is doctor.com install going there and over here you can find the instructions to install darker on different operating systems if you are on either Mac OS or Microsoft Windows you can install docker desktop installing docker desktop is very very easy if you are on Mac you can click the link install docker desktop on Mac you can download the docker Desktop for Mac from here by clicking the download from docker hub button once the download completes all that you need to do is double click on the Installer and drag the docker icon into the Applications folder and that you can double-click the doc without app from the Applications folder to startup docker and once docker starts up you should see something like what I see in here so this is the thing that you should be able to see installing it on windows also should be very easy all that you need to do is go back to the install page click Microsoft Windows in here you can download dock a desktop for Windows and the installing procedure is very very simple just double click the downloaded exe follow the instructions which are shown on the screen it might ask you for our system password so go ahead enter it and make sure that you follow through all the steps and install the docker desktop application you can start docker desktop up by searching for darker space desktop once you launch it up you should see the same well kind of a window in this status bar the installation on Linux however it's much much more complex so first you need to choose the distribution of Linux you are on and based on it you can follow the instructions which are provided on this specific page after installing docker launch up your terminal or command prompt and the thing you need to see is when you type in docker - - version 1 of the latest tuitions of docker so I have a version 19.0 3.1 make sure that you have a version which is at least 19 or greater if the step be quickly looked at the installation instructions for docker make sure that you are able to execute this command and I'll see you in the next step until then bye welcome back in the step let's discuss a use case where docker is most useful you're working on a team you are the star developer in the team you're working on a challenging project with very tight deadlines you don't want a application deployed to an environment quickly you have a very good friend of yours working in the operations team and you go to him and tell ok let's quickly deploy the application to the QA environment and you tell him ok launch of terminal he launches up terminal on Windows you might be using command prompt so launch of either terminal or command prompt and type this along with me he says ok let's check if docker is installed docker - - version type it in ok docker is installed so he says ok greater than 18 you're good now let's run the application let's deploy the application run this he says docker run in 28 min / - do - rest - API - H - colon 1 dot 0 dot 0 dot release it says ok this is the command go ahead and run it you press ENTER and you see that lot of magic unfolds your friend from the operations team asked what's happening you tell him ok wait hold on let's see what would happen and you'd see that right now it's downloading something it's pulling something it's downloaded a new image it says and you are seeing not that a spring good application is being launched up and you'd see that in about 20 seconds we are able to launch up a spring boot application your operations team friend is stunned he tells you hey on this machine Java is not installed how is it running your friend in the operation steam is actually working in a few older projects he's used to the manual approach he usually gets a document which says okay you need this hardware and you'd want to install Linux XYZ version and on top of it install Java 8.5 dot ten installed Tomcat eight dot a dot B and then not this jar and then run it using this command and what he tries to do typically is try to follow these instructions and install the application and typically he makes a lot of mistakes when I'm looking at a document and trying to type it down a multiple set of instructions there's a high chance that I make a mistake while deploying something he's asking you now how are we able to deploy this application that you're built so easily you tell your friend okay that's the magic of docker now I know that's exactly the question in your mind as well let's look at what's happening behind the screens in the subsequent steps I'll see you in the next step until then bye welcome back in the previous step we were able to quickly launch up an application just running a simple instruction and your friend from the operations team is very very curious he's asking where is this application downloaded from you have typed in something in here in 28 min to do REST API h2 what does this mean what is this and where is this coming in from so let's answer some of the important questions in this specific step over here when we run this command what is happening is an image is downloaded from where from something called hub dot Dugger docker dot-com hub docker comm is something called a docker registry registry contains a lot of repositories a lot of different versions of different applications and because this is a public registry anybody can access this typically when you are working in an enterprise we would be using private repositories so that our images can only be accessed by somebody who has the right credentials if this is the registry where our application is how do we locate our application right so over here you can type in - R and type in in 28 min which is the name which we used in here so in 28 min / type in to do - rest api h - if you type this in and press enter you would go to something called a repository so a hub docker calm is a registry it can contain multiple repositories and inside that in 28 min high to do rest api h2 is a repository storing all the versions of a specific application so this is something that hosts a number of tags and we specified 1.0.0 dot release as the version that we would want to use now you might be wondering what does this image contain you'd see that this image is about 102 MB this image actually contains all the things that your application needs to run it contains the right software for example Java a specific version of Java Java 8 or Java 11 whichever version would want to use it contains all the libraries your API needs your to do rest API I might need 15 libraries it contains all of them and it contains any other dependency that your application might need to be able to run when we ran this command this image was downloaded to our machine so a local image was created so from the registry the image is downloaded to your machine and once the image is downloaded it is ran as an application in your machine and this is what is called a container image is something static so on the repository image is a set of bytes that's it when it's downloaded even then the image is just a set of bytes and when it's running it's called a container so image is a static version and container is a running version and for the same image you can have multiple containers running now you might be wondering hey Ranga all this is great I see that the swingbed application is running but I would want to be able to access it how can I do that if you go further down you would see that it's running on port 5,000 let's go and try to run it localhost 5000 actually the URL for this is localhost 5,000 slash hello world whoops error what's happening why is there an error just press control C this would terminate the running container and let's do a clear and go up and try and run this command again however this time with a option so we need to put option called 5,000 5,000 : 5,000 why do we need this I'll explain that I will press ENTER to start kicking off the process what happens is by default any container that you run is part of something called a bridge network in docker you can kind of think of it like an internal docker network nobody will be able to access it unless you specifically expose it onto the holes on to the system where your container is running so what we are doing in here is we are saying I want to take the internal pool the container port 5000 and map it to a host port through a port on the system where the container is running which is 5000 so now I would be able to access the application on port 5000 you'd see that the application is launched up yep it took about 20 seconds I talked much more than that I guess and now we would see that I am able to access the URL if you would also type in - beam you would see that there are a couple of other api's which are exposed in here I'm using Chrome and inside Chrome I have adjacent viewer plug-in that's the reason why it's appearing to be perfectly formatted in the step we got a quick overview of a few concepts related to docker let's do a quick review of what we have discussed until enough when we execute the command the image is downloaded from something called docker hub docker hub is something called a docker registry registry contains a number of repositories when we are specifying the name in here it's actually named of one of the repositories and we are specifying which version which tag of that repository to get and once we specify that we saw that the image was downloaded and run the running version of the image is called a container image is a static version and the running dynamic version of it is called a container and at the end we also saw that we had to publish the container port to a host port to be able to access the application I hope you are having an interesting time and there are a number of other docker concepts you would want to learn I'll see you in the next step until then bye welcome back in the step let's play around a little bit more with daca images and docker containers what I'll do is I'll stop the running application if I press ctrl C you would see that the container which is running would be killed if I do a ctrl C right enough and try to run the application oops it's down now you'd want your application to be always running you don't want it to be killed when you do ctrl C how can we do that let's go clear down here let's go back to the instruction which we ran earlier and over here what I can do is have add an option called - D so - d stands for detached mode so what we want to do is we would want to run the container in the background you don't we don't want to tie up the terminal to the lifecycle of the container so you'd want to detach it from that let's press ENTER you would get a container ID and that's it you don't see any of the locks if you want to see the logs you can say darker logs and the oops and the ID of the container so I'll copy and paste this in you can also type in a subset of the ID you can also say C 9 B 5 instead of the entire thing so if I do docker logs you can see the sum of the logs from that specific application if you want to keep following the logs the way you can do that is by saying another option so docker locks - F what does this do this would start tailing the logs it would start following the logs of that specific application so if there is any new log coming in I would be able to see it actually none of the basic URLs are actually generating any of the logs so what I lose I'll type in a complex URL which is exposed by this so it's JPA - users - in 28 minutes - to dos this will not really return any data but it would actually execute a query and you'd be able to see the query in here in the log so what we are doing in here is tailing the logs so we are looking at the logs of the application you can press a ctrl C to stop tailing the logs let's do a clear again and we want to see what are the containers which are running I can do docker container LS you can see that this particular container is running for about three minutes you can see that a name was also assigned to this specific container it's called blissful and thus coving don't ask me how the name was generated and it also assigned a ID actually this shows only the first few letters of the ID earlier when we ran the container we were able to see the big string that's actually the complete ID now what I would want to do is launch up another container from the same image earlier I said we can run multiple containers from the same image what I can do is love I can run another version of the same application on port 5001 so we are doing docker run - P 5000 won : 5000 - d and the same thing that we used earlier let's see what would happen we are also running it in detached mode so if I do a docker logs - f38 1 5 5 which is like the first five digits from here you can follow the logs we are not tailing the logs which are generating from the second container which we are launching up cool the tomcat has started on port 5000 it says right but how do we access it the way we can access that is not by 5000 you would see that the way we'll need to access it by using 5000 won so if I do 5,000 won you would also get hello world back so now we have two instances of the application running one on 5000 the other one on 5000 won isn't it awesome if I disconnect from the logs so we just ran the command docker locks - F and we disconnected from it and now I can say docker container LS what does it show it shows that there are two containers running and these two containers are created from the same image now I want to see all the images which are present in my machine docker images what does it bring it shows that we have one image in here thing is the docker images only shows the images that are local to us the images which have been pulled from the docker registry it's not completely showing all the images which are present inside the docker registry inside the docker hub if you want to see any image down here the first thing you need to do is to pull the image down and once you pull the image down you would see that when you type in docker images the last command which would be looking at in this specific step is something called docker container LS be used is earlier right dock container LS really lists all the running containers I'll add an option - 8 you can see that this shows all the containers irrespective of their status you can see that these two containers are running up three minutes up seven minutes however these two containers have exited eight minutes ago exited 24 minutes ago so docker container LS - a shows the running containers and the stopped containers now before we end this step let's stop the containers which are running how do we stop the containers which are running like a container stop and I can pass in the ID of the container I will enter three eight one five five which is the first five digits so three eight one five five and I'll say docker container stop the other one which is running in here is c9p so c9p five something unique at the start to identify the container is more than sufficient you don't really need to enter the entire idea of the container and now you'd see that none of the urls would be working and when I do a docker container LS - a you'd see that everything is now in exited status in the step we talked a little bit more about images and containers and we ran a few commands around images and containers I'll see you in the next step until then bye bye welcome back in the step let's understand the architecture of Dhaka the place we were running the commands in is called a darker client and when we type something in the Dhaka client the command is sent out to something called a darker demon or a darker engine for execution so even the local installation of docker uses a client-server kind of architecture so when you install docker desktop we were installing both the docker client and the docker demon the docker daemon is responsible for managing the containers it's responsible for managing the local images and it is responsible for pulling something from the image registry if you need it or pushing a locally created image to image registry the first two parts of that is very easy right dr. Damon is responsible for containers and local images earlier we created a number of containers if I do a docker container LS - a you'd see all the images that we have created and stopped all these containers were created and stopped all these containers were managed by the docker demon or the docker engine which is running on our local machine the docker demon also manages the images which were downloaded the docker demon knows that there is a local image for this specific repository and this specific tag now if I would want to run a container based on the same image let's see what would happen so I'm removing the - D because I would want to see the logs right here and let's canoe to run it on port 5000 so dock around - P 5,000 5,000 and I'm using the same image nap name and the same tag 1.0.0 release what would happen you'd see that it's not really downloading the image again it knows what containers and images are present in local and it knows that this specific thing is already available and it runs an existing thing now I'll stop this ctrl C and now I'll use a different tag of this so instead of 1 dot 0 dot 0 dot release I would do a different tag 0 point 0 point 1 - snapshot so I'm typing a zero point zero point 1 - snapshot we are running the command in docker client the docker client sends it to the docker demon and the docker demon now sees that the image is not available locally it says in this repository with this tag the image is not available locally so what it's doing it's going to the registry and fetching that image down for us so it will fetch down the image and then run it as a container you can see that it's downloaded a new image for us so the docket daemon is responsible for managing our local stuff and also pulling something from the image repository if something is not available on our local one of the additional capabilities that document demon has is it can process instructions to create images as well until now in this course we have been using images which are already created but later in the course we'll be creating more than 10 different images for different kinds of applications for REST API full-stack applications and microservices at that particular point in time you would see that the docker daemon would help us in creating those images and also pushing the images to the image registry so that somebody else can make use of them in this quick step we understood the different components which are installed when we install docker desktop on our machine and we also understood the responsibilities of each of those components we talked about docker client which is responsible for just sending the commands to the docker demon we talked about the fact that the docker demon is responsible for managing our local containers local images it's responsible for pulling images from the image registry it's responsible for creating images and also pushing out images to the image registry I'll see you in the next step where we talk a lot more about docker until then bye welcome back I'm sure you are itching to get your hands dirty and and type in a lot of docker commands but one of the most important things is you should understand the big picture around why docker is becoming famous one of the things we saw was installing docker on our local machine was very very easy so developers can use docker easily now what's happening these days is most of our environments are deployed on the cloud the awesome thing about docker is you can install docker on cloud also very very easily most of the cloud providers actually provide container based services so they provide services where you just need to tell run this container and it would automatically run on the cloud let's get a 10,000 feet overview of this phenomenon in this specific step before docker virtual machines were very very popular you have the hardware you have a host operating system installed on top of the hardware and we have something called the hypervisor to manage your virtual machines so each of these was a virtual machine so you have virtual machine one virtual machine - Oh chill machine 3 and each virtual machine had a guest OS and on top of it you have the software that you would want to install to run your application and on top of it is your application one of the major problems with these virtual machine architecture was typically these are heavyweight we had two operating systems host operating system and guest operating system and that makes the whole thing a little heavy and that's where docker comes in if you have some infrastructure and if you have some host operating system installed on top of it all that you need to do is install the docker engine for that specific operating system and talk I would take care of managing these containers the docker image contains all that is needed to run a container all the libraries all the software are directly part of these containers because there is just one OS the host OS docker is relatively lightweight and therefore it is very very efficient and that's why you would see that all the cloud providers provide a number of visas around darker today as we speak it's very very easy to deploy something related to docker onto any of the cloud providers as your provides a service called as your container service AWS Amazon Web Services provides a service called elastic container service so the thing which we are understanding right now is the fact that using docker on local is very easy and using docker on the cloud is also very easy and that's the reason why docker is becoming really really popular shooting the last few years okay that's all theory done and dusted and let's move on to the next step we would start getting our hands dirty and execute a number of docker commands I'll see you in the next step until then bye welcome back in the step let's play around with images let's try different commands which are related to images with docker so if I type in docker images we have done this number of times over here we are seeing couple of images right so we are seeing the repository and the tag you can give two tags or three tags multiple tags to a single image to the same image I can give multiple tags how can I do that the command is docker tag so I would want to tag this repository and this tag so I would want so this repository this tag I want to add a new tag I'm going to use the same repository name and colon latest I am saying this is the latest version of this specific repository what would happen if I say docker images now you would see that the image is shown twice the same image is now being shown with two tags so you can see the image ID is the same 5 6 0 5 6 0 however it's now being shown with 2 different tags typically a lot of projects in addition to the release version will use a specific tag called latest on the most recently released version of that specific project however it's very very important to remember the fact that latest does not need to always point in to the latest release it's just a tag it's just another tag like 1.0.0 dot release it's not an automated thing it's a thing that you need to manually add so if latest is actually pointing to this then latest would actually download this version of your repository the interesting thing with docker is if you do a docker run or a docker pool let's say my sequel so my sequel is one of the images the repository name for my sequel image is very very simple because it's an official image so I'll say docker pull my sequel and without specifying of and you can see that this is pulling down the latest version if you don't specify a colon tag what happens it would pull the latest tag however it you have to remember the fact that the latest tag might not really be the latest so go to repository check the tags and check which release the latest tag is attached with and then make sure that you are really using the latest release now if I do a docker images after the pull of my sequel is completed you'd see that my sequel is also listed in here now one of the important things that you need to know about the pull command is the pull command just downloads the image from the registry to your local it does not run it if you want to run it you need to use docker run docker run checks if it's available in the local if it's not available in the local then it pulls it and creates a container so until have we discussed the fact that a single image can have multiple tags the latest tag might not actually be the latest and that pull can be used to pull an image from the registry to your local the other thing we talked about is the fact that my sequel is a official image now what is a knavish official image let's do a docker search my sequel I would want to search for any image which contains my sequel let's do that so if you don't know if there is a specific image that exists with that specific name you can do a search to the docker search my sequel you can see that over here the first one which is listed is my sequel and it says official okay so this is something which is docker official you can see that there are a lot of docker official images and there are a lot of things which are not official as well so what is an official image basically doc official images are a curated set of docker repositories basically docker has a team which looks at these images make sure that they are meeting certain standards and they publish all these content in the official images so whenever you'd want to use image for some software let's say you'd want to use a my sequel image or let's say you'd want to use a tomcat image or you'd want to use a Java image make sure that you are using an official image let's look at a few more commands related to images you can do he made history and look at the history of our image let's say I want to look at the history of this specific image I'm using the image ID you can also use the repository name : tag what you are seeing in here is the steps involved in creating that specific image you would see that in certain steps there is a file size attached so there is a layer added in with about 5 MB and after that there are a number of instructions which were run to create that image and after that there is another layer added in with 99.3 MB this is the largest layer in here and this one is typically the layer where we add in Java so the JDK which is added in is about 99 MB and after that there are a couple more instructions which are running you can see that we are exposing pool 5,000 on that specific image and you can see that a file is added in typically when we are talking about spring good application that's a jar file so you can see that that size is about 38 MB and there were a few Java options which were set and a command is said to run something when a container is created from this we look at all these commands a little later entry-point E&V add expose volume we'll talk about all these commands a little later but the important thing for you to understand is when you do a docker image history and provide our ID of the image or repository name : tag you would get all the history all the steps that were involved in creating that specific image you can also do something called docker image inspect and use the ID of the image when I do the inspect you can see that I can see the tags you can see that this specific thing has two tags we just added a tag called latest on this thing you can see the digest you can see when it was created you can see the containers which were created from it some configuration related to that you can see the entry point which is basically the command which would be run when you create a container out of this image and launch it you can see that it's running some complex version of Java - jar slash Abdur jar so it's launching up the Abdur jar as Java - jar you can see the darker version which was used to create it you can see the exposed ports you can see that this is actually running on five thousand you can see all the environment variables which were set path Java home Java version Java Alpine version and all that stuff and you can see a lot of information about the folder structure the different layers which are present and all that stuff some of this might not really make sense to you fair enough but for enough remember the fact that there are two important commands docker image history and docker image inspect you can also remove image from the local so I can say image remove the important thing is this will only remove the image from your local machine it will not really delete it from the docker registry so if I do a docker image remove and let's say I specify the image ID for my sequel what happens you'd see that the image would be removed from our local so if I say docker images you'd see that there are only three images which are present in here in the step we looked at a lot of commands related to docker images we saw how we can tag a image we can saw the fact that a single image can have multiple tags we saw that we can search for an image by using docker search we saw that there are a few images which are called official images typically things like Java my sequel and a lot of standard software have official versions it is always recommended to use official versions when you can we also looked at command like docker image history docker image inspect and we also were able to remove image from our local by using docker image remove I hope you are having a wonderful time and I'll see you in the next step until then bye bye welcome back in the previous step we explored a number of commands related to images in this step let's explore a number of commands related to containers earlier we created a container by using docker run - P 5000 : 5000 and the repository name followed by the tag the interesting thing is the fact that this is actually a shortcut for command actually called docker container run so typically what you'll be using is docker run but the things you need to understand is actually what you're running is a container so we are creating a container from this specific image so you'd see that this would actually launch up a docker container I'll use - d to launch it up in a detached mode so you'd get the ID of the container one of the interesting things is you can pause and unpause a container so you can say docker container pause and give it the unique identifier it can be entire ID or I can use a part of the ID the starting four digits of the ID and pressing enter you can see that now this container would be paused so if I try to do docker logs - F so I'm following the logs of this specific container six four seven eight you'd see that the application is started up but when I try to access the URL I'll not get a response back because this is in a spas state how can I unpause it I'll go ctrl C and now I would say docker container unpause six four seven eight and you'd see enough that you would get a response back so pause just stops the container in that specific State we already explored this top command docker container stop it would stop a running container you can also inspect a container so I can say docker container inspect this is very similar to the command that we ran on the image so I'll say six four seven eight again when you do it over container inspect you can see tons of details about that specific container the image it is coming created from a lot of a metadata about the container itself when it was created what is the current status you can see what's the platform the details about the image the pole bindings the volumes a lot of stuff you'd be able to see in here whenever you are expecting something to happen with a container and it's not happening probably this is the place you can look at this would give you tons of data which you can look at and see what's going wrong the other interesting command related to the containers is docker container prune before that let's do a docker container LS - a you can see that we have one image in running status up three minutes and most of the other images are in a exited status and let's do a docker container prune this would remove all these topped containers so yes I would want to remove all the stopped containers and let's now do a docker container LS - it you can see that except for the running container all the other containers are removed so if you want to clear out all the containers which ran docker container prune earlier we looked at this top command what does the top command do we saw that this dot command gracefully shuts down the container what does what do I mean by a graceful shutdown let's see that in action if I do a docker container LS right enough you'd see that I have one container running I want to tell the locks for it so I'll say docker container logs - f2 tale the locks so I would want to keep following the logs which are coming out of it and I'm entering the first three digits of the ID from here so let's press it so now we are able to tell the logs I'll open up a new terminal so I'm opening up a new terminal and what I would do is docker container LS and I'll send docker container stop 1b1 let's see what would happen over here you can see that at the end after the starting of the application there is something called shedding down executor service so if setting out the executor service it's closing the entity manager factory and then it's dropping the table sequences and it's shutting down the connection pool so you can see that after I called stop on the container the container was given some time to finish its processes to shut down gracefully so things like closing out the connection pool things like sharing down the executor service the container was given time to do all that stuff in technical terms when I do a container stop the signal which is sent to the container is something called sig term it means take about ten seconds and make sure that you gracefully complete your execution what I'll do is I'll do a clear and I'll start up another instance again I'm using a detached mode so I'm stop starting in another instance of that container again let's go back and now over here I would say docker container kill the idea would be little different right what's the ID 9 b8 before I kill I would actually want to check the status so I'll say docker logs - f9 b8 so we are following the logs the application has started up let's kill it right now let's see what happened the container was stopped as it is it was not really given time to do anything it stopped dead in technical terms what happens is in here a signal called sig kill is sent out to the container and it immediately stops the command which you should use most of the times actually 99.99% of the times is is docker container stop you'd want to give you a container time to shut down gracefully now before we get to the next command let's actually run docker container prune before dogger contain a prune make sure that you don't have any containers running so I've stopped all the running containers and I am doing a docker container prune to remove all these topped containers I'll do yes so we have no containers running right now so if I do a dock contain - a there are no containers down here at all now what we want to do is we want to start up our earlier application you want to do a docker run - P 5,000 5,000 in a detached mode right now do you want to add a restart policy of always so what we are doing is we are adding - - restart is equal to always this is called a restart policy two of the most popular values for listed policy always and no the default is no what we are specifying right now is always if you specify always and start this up so I am specifying always and starting this up I'll do a daughter container stop five zero one what I'll do over here is I'll restart the dock or desktop before doing a restart let's actually list the containers which are present in here so LS - a you can see that this has exited out but we have created this actually with a restart of always so what would always do what always does is when you restart your local desktop I'm doing a restart of my local desktop you would be your no warning that's okay let's go ahead and restart you can monitor the status in here it's being stopped right enough it's now saying it's starting up wait until the status shows started okay cool now it says docker desktop is running that's cool and now I am doing a docker container LS what's happening you can see that the status of this container is enough in running what happened this container is automatically started because we specified a - - restart is equal to always whenever you restart you will dock up and the talk--i daemon restarts it sees if there are any container with the restart policy of always if there are any it would launch them up the only way you can actually prevent the restart from happening is to first stop this up its a docker container stop 5:01 give it some time to gracefully shut down and do a docker container prune this would remove all the stopped containers so if you do a docker container LS right enough nothing is present so enough we have deleted that container completely so there is nothing present right now with a restart of always so the reset policy also is very very useful especially if you have things like databases which you'd want to keep them always running you can state set a restart policy of always and even if the docker demon restart by accident at the startup of the docker demon that specific container would be always launched up in this step we looked at a number of commands related to containers we looked at pause and pause inspect we looked at prune we looked at the difference between stop versus kill and we looked at what is a restart policy I hope you are having a wonderful time there are just a few more things you would need to know before root start actually exploring the world of creating docker images we would want to actually create docker images for our REST API for our web applications for full-stack applications and micro services we will get there in a couple of steps I'll see you in the next step until then bye welcome back in the last step before we start actually looking at the applications and building images for them let's look at a few more interesting darker commands the first command we will be looking at is dock events what I'll do is I'll go to the second tab which is present in here I look clear and run docker events initially I'm not seeing much action happening so I'll do a docker container LS to see what containers are running right now I have one container up and running so let's stop it so docker container stop c70 now if you go to the next tab where we have docker events you can see that a lot of events are happening the daka events helps us to see what heap events are happening with docker you can see that this container is now being stocked you can see that this container has disconnect from the network you can see that this volume is unmounted we'll talk about volumes a little later now let's try and launch up another container so I'll launch up the same image that we used earlier - P 5,000 5,000 - D in a detached mode and let's launch it up and over here let go to the events and you can see that there are a lot more events which are happening so if you want to see what's happening with your dock and environment what is it doing you can do documents and you can see what's happening in the background it keeps running continuously now I'll do a ctrl C to terminate the docker events and we are clear the other interesting command is docker top what does it do the docker top actually is used to check what is the top process which is running in a specific container let's do a docker container LS and this is the container ID which is running right now so I can say to occur top and give the ID of the container and you can see all the processes which are running in that specific container you can see that there is just one process running in that container and the process is the running of a jar so Java - jar / hot dogger the other interesting command is docker stats so docker space stats and this would show all these stats regarding the containers which are running so right now we have one container which is running and you can see what its name is how much amount of CPU is it making use of how much memory is it making use of it is use making use of over 320 MB it has a limit of about 2 GB of memory and you can see that it has a memory percentage so it's using about 16% of the memory which is allocated to it 320 out of 1.95 you can do the math so you can see all the metrics stats around your running containers now I want to run another container with from the same image how would this one I would want to run it on port 5000 won and for this one I'd want to add in specific memory and CPU limits how can I assign that I can tell over here saying - M Phi - L M so what I'm saying is this specific container can only use at a maximum fight well Meg of memory I Phi 12 megabytes of memory you can also use something like one geek or you can say 0.5 gig so let's change to Phi 2 L m and you can also assign a CPU quota so you can say - - CPU - quota and you can put in a value in here typically the entire quota which is present is 100,000 so out of 100,000 which is 100% how much CPU quota do you want to allocate to this specific container I'll say around 5,000 so we are assigning 5% of the CPU to this specific container that's a very less thing so let's see what would happen it tries to launch that container up and over here you can see that over here this container is using about 5% so this is where we are running our docker events actually docker stats and you can also see that the limit is now set to just Phi 2 l mb and because it's using just 5% it would be very very very slow in starting up if I do a docker container logs and say 3 FB actually I should have said - F 3 of these you can see that it's hardly doing anything at all so what I lose I'll give it a little bit more CPU so I'll say docker container stop 3f be even the stop is taking a long long time because we have not given it enough CPU right even to do this top it needs to gracefully shut down right so let's do a run and let's give a CPU quota this time of a little bit more so let's actually make it 50,000 so we are giving it half the CPU and let's run this right enough and you would see that right now it's using about 50% that's half and you can see down here that the amount of memory increase is much much higher so it's starting up faster and now if I actually do a docker container log - F on this particular one five seven F right so sorry it's 5 7 f you can see that there are certain things that are happening so not far as fast as earlier because we are only assigning half the CPU but you would see that it's going fast enough let's close that control C and what we are interested in is in the next command which is called docker system DF what does it help with it tells us to look at all the different things that you're darker Damon manages to document it Damon manages your images your containers we will talk about something called volumes a little later you can see all the details around that you can see that there are two images which are downloaded you can see that one of them is active you can see what's the size of them in total you can see what are the containers which are present how many of them are active how much size are they making use of and you can see all the local volumes cool in the step we looked at a few more commands little bit darker events which is used to monitor the events which are happening with your darker engine or the dr. Damon a little bit darker top which helps us to see all the processes which are running in a specific container we looked at docker stats which gives us the stats for each of the containers which is running how much memory is it making use of how much CPU is making use of and all that stuff we also looked at docker system DF which helps us to look at what are the resources that are being managed by our docker daemon and how much size each one of them have and we also looked at how you can set memory and CPU limits for your containers until now we have been playing with images which are already created how about starting to create images that's what we would be doing in the next section you would start creating images for a number of projects if you are excited to do that I'll see you in the next step until then bye welcome back welcome to this new section where we would start creating images dacha images for a number of springboard projects we have a number of projects lined up for you a REST API to do web application to do web application connecting to my sequel database we have a full stack application with spring boot and react and we have a number of micro services inside the micro services folder as well what do you do during this course we would actually play with all these projects understand them and then create docker images for them and run them as part of docker containers and to be able to do that we need to download them how do we download them either you can do a git clone and clone the specific get repository or you can download the zip so you can click download zip once you download the zip what I would recommend you to do is to extract the zip to some folder on your local machine what I have done is I have exploded it out to a folder called docker crash course master which is present down here so all the content from the zip file is now present in this specific folder now you can start up Eclipse and choose a workspace anywhere on your hard disk and say launch make sure that you are using one of the latest versions of Eclipse contribute on welcome window and you can do a file import existing maven projects I'll import existing maven projects and next you can choose the folder where you have extracted the zip file to have extracted it to in 28 minutes get doc a crash course master so that's where it's Pleasant and over here you'd see that there are a number of projects which are present in here let's deselect all and to start off what we lose will project import projects one which is hello world REST API we'll import project two which is to do web application hits two we'll import project three which is to do web application my sequel we'll import project 4 which is the full stack and will import the micro-services projects alone so we'll import from 0 5 will import the currency exchange service and we'll import currency conversion service so out of the projects which are present there we are choosing the first six projects 0 1 2 0 4 and inside 0 5 micro services there will be multiple projects out of which we are choosing just the currency conversion service and the currency exchange service and do finish if this is the first time you are actually importing this specific versions of spring boot this import would take a long time because this would need to input all the dependencies for 6 different projects and all these are almost real world kind of projects so they have a lot of dependencies which are used in there so you would see that it might take a lot of time now if you have any problems with the import what you can do is you can refer to the troubleshooting instructions as well as you can look at this specific playlist so among the installing guides installing Java Eclipse and emitted maven if you open this up these are a set of 4 videos inside a single playlist and the fourth video in here would help you with troubleshooting any problems that you have so you can either play that video or you can actually use this troubleshooting guide which is Pleasant in here so this should help you to solve any problems that you would face with importing them in typically you should not really face a lot of problems and at the you would see that everything is imported in properly I am sure you are excited to run these applications and create docker images for them I'll see you in the next step until then bye bye [Music] you you