Welcome back.

An important part of learning Docker is to learn all the documents.

Let's play with Dockery majors and look at all the commands which are related to Dockery majors in this specific step.

If you do a darker images what would you would see.

You would see all the majors that are present inside our local machine.

You can see that we have Hallowell Java nowadays python and Hallowell REST API which we brought in which we pulled in one of the previous steps until the baby were running the container was using the command Docker run instead of doing a docker run.

You can also do something called a docker pull.

So what does Dokoupil do.

Let's do a dog pull my sequel.

So I'm just saying Docker pull my sequel I'm not putting a clone or anything I'm just putting pressing into right now so you can see that it's using a D for tag.

So if not plus providing a tag what happens is Docker uses the latest as the tag.

So it to look at if there is something if there is a my sequel image with the tag latest and it would pull that down the my second image download would take a little while because it's a large image.

But the interesting thing about the pull command is that it will not launch up the container so it will not create a container from the image.

It will only pull the image and it will make it available locally.

So let's wait for a little while while the pull is completed.

Yep.

The police completed and now you can see that the Mexican image latest is present on the local machine.

So if I do clear and do or darker images you'll be able to see that my sequel image is also present in our local machine.

However if you do a docker container Alice you would see that the DA bicycle container is not really running because the predicament only pulls the image it will not run a container for it.

Now you would want to find out what are the different darker images present on the docker these two you would want to do a search. 

How do you do that.

The way we can do that is by using Docker search.

And let's use the same thing like I'm searching for my sequel.

So Docker search my sequel you'd see that a lot of images come back.

So you can see that there are a lot of images coming back and some of these have an official of okay.

So if you don't know what are the images which are present for specific thing do a doctor search my sequel and I would recommend you to actually look for an official image.

So if you'd want to run any software like my sequel Tomcat or Java as a docker container what you'd need to do is do a search and make sure that you use an official image Docker has a team which looks at all the images and make sure that they're meeting certain standards.

I mean they are secure and all that stuff and then they publish all these images as officially majors and therefore these official images are much more reliable than are the unofficial images.

So if you are searching for an image do a docker search now let's do a docker images and this would show all the list of images which are present in here.

One of the interesting things about Docker images is they are built in number of layers.

So you'll have a layer with the operating system you'll have a layer with the software.

Then you'll have a layer with the specific application binary.

And how do you see all the layers which are present inside the image.

You can do a docker images actually Docker image history and you can use the repository name and the tag name.

So the repository name for this for example is invented Minghella Hallowell Java and the tag name is 0 dot 0 dot 1.

Please let's get it right and present.

So we actually seeing the Docker image history for this Pacific image and you can see that there are a number of layers which are listed down here.

So a very very small operating system layer after that you have a large Java layer.

So this is where the java installed we are exposing port five thousand and after that we are copying the jar file so you can see that each one of those are added in as a separate layer.

The exact details of this is not important at this particular point in time.

The most important thing for you to understand is Docker image is built as a number of layers and you can look at all the layers by using Dockery made history and specifying the image name.

The other interesting thing is you don't really need to specify the tag as well.

You can use something called an IED.

So if I do Dockery majors there is an image I.D. that you can see.

So this image I.D. is unique for each of the image releases so for a specific repository for a specific tag there's a major I.D. so you can use that as well as a docker image history and I can pass this in and this would show the different layers which are present behind that specific image.

Now the other command that you can do is to look at the details behind each of these images.

The command is darker image inspect and I am passing in the idea which I copied in earlier so I can do a darker image inspect and you'd see that you can see a lot of details about that specific image you can see that there are bags you can see that there is an I.D. which is present for it you can see the created time stamp you can see the containers that are part of the image you can see which port they're exposed in what are the environment variables which are present in there what are the ports which are exposed you can see how the application is being launched that's the entry point you can see which specific version of Docker was used to build that image you can see the operating system and you can also see the different image layers.

So two interesting commands that we have looked at until now our Dockery made history and docker being made to inspect Docker images we will give you details of the different layers which are present and Dockery images we will give you a lot of detail behind the screens for that specific image let us do a clear right now and let us do another command called Docker image remove it's easy to guess what this does right.

This removes the image.

So let's I would want to remove my secretly made so let's not try and remove this one so I'll see Dockery measuring more my sequel what would happen if I do a darker images you would see that my sequel is no longer present in here.

So if I now try and remove under the one to Docker image remove let's say I would want to remove the hello world application what would happen will I be able to remove the image UPS actually I should use the image I.D. or I would need to use the repository followed by the tag.

So now if I do this you'd see that it's seeing an error.

So whenever you're trying to remove an image and you get an error like this it means that you have a container which is referencing this image.

So if you have a container which is referencing the image you cannot remove it earlier the Prudie my second image but we did not really create a container for it.

That is the reason why we were able to easily delete my sequel image.

But if you want to remove image for which a container is already existing the first thing that you need to do is to remove the container.

So docker container remove this one the idea of the container which is being listed in here.

So this would remove the container and now I can remove the image so you can see that there is another container which is using that specific tag.

So let's remove that as also Docker remove and it is six seven a six seven A.

That should be sufficient.

Let's see if there are more images which was using.

Yep.

There are a lot of things that we have created a little bit and a lot of containers using that specifically made so let's remove the other one as well.

E 3 5 so right now we are kind of using a trial and error way of find removing the image or actually identifying the containers which are related to each mage deleting the containers and then we are now able to remove remove the image from our local machine.

So now if I do a darker images you'd be able to see that there are only three images which represent the other option of identifying all the containers which are related to a specific image which are running right now.

Docker container a less hyphen.

So now I can use this to identify all the containers which are present.

So it would I would wanted let's add delete the Hallowell rest api.

I can see that there are two containers which are present in here and both of them.

One of them is in exited status so I can easily delete this but if I would want to delete this one what I would need to do is to stop it and then delete the container.

So if I actually play docker container remove the for one B.C you can see that it's up and running.

So this will not be able to do.

You can see it says you are trying to remove a running container you'll not be able to do that.

So the first thing that you need to do is stop so docker container stop and then you'd be able to remove that specific container out the other one which is present in here is f 72.

So that's the only one Hallowell WPA.

Are there any other hello world rest api.

I do not see any of them here.

So let's remove that to Docker containers three more and F seventy seven.

No let's do a docker images.

And now I can do Docker image remove this specific one.

You can see that the image is now removed as well.

If it were Dockery majors you can see that in here as well.

So in this step we were playing with a lot of comments related to darker images.

We started with looking at how you can search for a specific image.

We started with a search my sequel.

We also did our doc pulling my sequel.

We looked at a couple of comments to look at the details of the images Dockery made history and Dockery image inspect.

And after that we looked at the command Docker image removed.

The important thing about the Docker image anymore is it only removes the image from your local machine.

We are not really deleting the image from the Docker Hub so Docker image removed removes the image from the local machine and for us to be able to remove an image there should not be any running containers associated with it or that should not be any stop containers which are associated with it.

So we need to remove all the containers which are associated with an image and then if we have to remove that image from our local machine.

I hope you are having an interesting time and I'll see you on the next step until then. 

The way.

  • No labels