Docker Beginner Tutorial 9 - What are Docker Images | How to run Docker Images |

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome to this session on docker images this is going to be a very basic and beginners session on docker images and we are going to go very basic step-by-step and we will learn what are images how to pull image how do we run a container using an image and we will also look at some basic commands and some tips and tricks so let's get started and let me open my terminal and I am on a Mac so I am using a terminal if you are on Windows you can use your Windows command prompt or your windows powershell and on linux you can use your linux command line so here I will just say docker space - V - check my daughter is installed and I am using version 18 dot o 3 and then I will say docker images now this command will list out all the images on your system but as of now I do not have any images so I can run the command docker images space - - help so this gives us the usage of the docker images command so you can see we can use in this command with all these options and I will just show you how to use them but before that let me try to pull an image so I'm going to my browser and I will go to docker hub and here it is so you can log in or create an account on docker hub I have already created an account and I am logged in I am going to explore repositories and here you can see all these images so I can take any image for example here is an Ubuntu image you can also for some particular image you can search from here and I will go to I am going to get this Ubuntu image so I will go to details and here you can see in this is the pull command so to pull this image you have to use docker old Ubuntu so I will just say here docker pull Ubuntu and it is getting the latest tag by default because we haven't given any tag I will just show you how can you give X as well so it is now downloading the image so image is now downloaded successfully let me clear my terminal and now for another command docker images you can see we have got the Ubuntu image which is of size 81 point 2 MB this is the latest tag and this is the image ID and it was created four weeks ago so using the docker pull command we can get an image from a docker registry or a repository and before I go to the next command now let us understand water images so images are the templates used to create docker containers and basically these are files which has information about what all things will be required to create a container and container is a running instance of an image so when you run an image the container is created and images are stored in registries for example docker hub so docker hub is a kind of a registry where other where the images are stored now as we have pulled the Ubuntu image when we do not give any tag the latest tag is getting pulled but if we want we can also provide some tag for example these are the tags available I want version 18.04 so I will say da couple Ubuntu and I will keep the tag 18.04 so this particular tag will be pulled and I've done this so it will start pulling that particular tag for Ubuntu and here it is giving us a status download newer image for Ubuntu 18.04 so if you go to the docker hub you will find the tags here for every image or most of the images you will find these tags and here you can see all these X information so you can get any of these tags from here now let us go to some of the basic commands that you can use with images and I have these commands here let me also split mais so that you can see all these commands and the terminal so here we have seen docker images help command that helps us to view all the options we can use with docker images command then we can do da couple and the image name that we have already seen and then we have the command docker images this lists out all the images that we have and you can see we have now got the Ubuntu image with tag 18.04 and the latest one now if you say docker images - - help you can see we have our flag - cue which is the quite flat and it will only show the numeric IDs so if I say docker images - cue you can see it is only showing us the image ID and nothing else so you can use this then we have the filter flag so if you say docker images - f and you can provide some filters for example I am saying then link equals false so dangling images other images which are associated with a container or a running container so if I say dangling equals false I am getting both of my images because these are not yet associated with any container however if I say - F and I say dangling equals true then I am NOT getting an image so you can use this filter option as well and you can use this filter option along with other options as well for example I say dandling equals false and I also use the flat - cue so it will show us the images which are not associated with the running container and only the image ID so let me also let me again run docker images help command so we have seen - QN minus F you can run - a to list all the images for example you can say docker images and - a it will list all the images available on your system and if you use the - - digest slag it will show another column called digest which is again an ID that you can use for identifying the images let us not go deep into that I will clear my terminal and now we will see how to run an image so by running an image we actually create a container out of an image so if I can say docker run and I can give the image name which is open to now if I run this and now I see the containers I say docker PS and I can also say docker PS - a so we can see we have this container created which is created from the Ubuntu image but this is not yet running as of now so to run this container we have to run another command and you can go back to your docker hub and the image details here so on this docker hub page if you go down you will find different commands to run the container from the image and let me just show you we are going to say docker run and I'm going to use the flag IT for interactive mode and going inside the container and the image name and I will say bash to start in an interactive mode and so that I can start the shell I can also give the name to this container I can use the - - name flag and give the name this is my open - one and just started and you can see we are now inside the container if I say LS you can see this is the Ubuntu system and we are inside the container now and if I open a new terminal I am opening a new tab in the terminal and I can run the command now docker PS and you can see this shows us this is running let me take this out to show you in a proper way you can see this container is running this is the container ID this is the name we have given to this container and it got created 18 seconds ago and this is how we can create a container from an image so you can also inspect an image so let me run the command docker inspect and the image name that you have so here it will give you all the details of this image and it is going to be a big file so you can see the ID of the image the text we have so we have these two tags and then other information about the host name domain name author and everything and the darker version here and if you go down you will find all these layers so you can see all these layers so images are actually a layer of file systems which are stacked one over the other and when you say docker inspect any image you can actually see all these layers so of course we are not going very deep inside but we know that images are a stack of layers or nth file systems so I will clear the terminal and then you can remove the images by using the RM I command so if I say docker RM I and the image name now if I say docker images you can see the latest image is now removed and we just have the other image of Ubuntu which is for tag 18.04 I can also say docker RMI Ubuntu and the tag 18.04 so you can see it is unable to delete because it is being used by the container so we have to first stop the container so we will say docker stop and the container we can give the container ID or by name I can say my Ubuntu one this is the name I gave to my container and now I can remove the image but it is still not getting the mood because the container is still available it is not running but still available so either I can remove the container and then remove the image or I can use the minus F flag to remove it forcefully so now you can see it is removed and if we run the command docker images now you can see we don't have any images so this is all about images in a nutshell I hope the session was very useful for you I will meet you in the next episode of docker thank you for watching [Music] you [Music]
Info
Channel: Automation Step by Step
Views: 292,857
Rating: undefined out of 5
Keywords: docker images, docker how to create image, docker how to manage images, docker images beginner tutorial, docker images for beginner, docker images commands, docker images tutorial for beginners, docker images basic commands, how to delete image, how to see image details, docker beginner tutorials, docker free tutorials, docker trainging, devops training, docker basics
Id: QBOcKdh-fwQ
Channel Id: undefined
Length: 12min 15sec (735 seconds)
Published: Wed Jul 04 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.