Docker Beginner Tutorial 8 - Basic Commands | Docker FAQ | Docker Interview Questions |

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Applause] hello and welcome to this session on docker basic commands this is going to be a very easy and interesting session on learning the docker basic commands and I have categorized these commands as basic images containers and the docker commands used for docker system so these are the very basic commands and the very frequently used docker commands of course we will learn many more docker comments when we learn about containers images how to create docker images how to create docker files and we will learn about docker compose and all these things but this is a very quick and basic sessions on docker commands and using these commands you should be able to work with most of your requirements in a project working on docker so let's get started and let me open my terminal so as of now I am on a Mac operating system so I am using our terminal if you are on Windows you can use your Windows command line or you can also use PowerShell and if you are following this session on Linux you can use the Linux command line the only prerequisite is docker must be installed on your system and this we have already learned in the earlier session how to install docker so assuming that docker is installed on your system I will start this session and let me also split my screen so that you can see the terminal and the text side-by-side so the very first command is darker version and this command gives us the information about the docker client and the docker server which is the docker engine so we get information about the version of taça client the API version the go programming language version and similarly for server we get all these details so this is going to be a very handy command if you want to look at your client and server versions and the next command is docker space - V and this gives us the version of docker so as of now I am on docker version 18 dot 0 3 also you can use docker space - - version which will be the same command and it will give the same output let us go to the other command which is docker info and this command will give you a little detailed information about the docker that is installed on your system so you can see the very first section gives us the number of containers running cost stopped and the number of images as of now we do not have any images or container so we are getting 0 for all these fields and then the server version that the driver details plug-in information and other informations so the system time and all these things proxies and other things so of course you might not be interested in many of these but of course if you want to have some quick look into that information on the docker that is running on your system you can run docker info the other command is docker space - - help now this is going to be a very useful command in your dock Ajani because you can use this command to get information on any other command so the way you can use this command is for example you want to get information on docker images command so you can say docker images and then space - - help so here it is giving us all the details about docker images so the usage you have to use it like docker images and the options repository aggghhhhh and these are the options - air to show all the images - cue which is a quite flag to only show the numeric IDs of the images and so on so for example I want to say docker run so docker on is a command and I do not know the usage of docker and so I will say the current - - help so again it will show me all the options I can use with docker run so docker help is going to be a very useful command and the other command is docker login so docker login here you can use this command to login to your hub docker calm and whatever username you had clear so for example let me go to my browser and let me go to Google and go to docker hub docker hub is a repository for docker images and here if you want to pull or push your images and basically if you want to push your images to our docker hub you need to have a docker account created and you can see my account is already created and this is the username block of pal and in case I want to log in from the terminal I can use docker login and here I have to use the username and password so let me try login here I will give my username and my password and just enter and let's just wait and you can see login succeeded so this is I think going to be a very handy command now let us come to docker images and before I do that let me just shorten this string so this is a long string which is occupying a lot of space I will say export ps1 equals user name and dollar and space so yes I'm getting a shorter version so what I did just now was just to reduce the size or reduce the length of this particular name okay so now we have come to docker images so the very first command is docker images and this gives us the list of all the images we have and of course we do not have anything so we use the other command to pull the image here I can say docker pool and I can give the name of any image so if you are on docker hub and you can get any image let me go to the repositories I will go to explore repositories and here you can get any repository for example let me say I want to get an Ubuntu image I will click on Ubuntu and press enter and you can see the sister bun to image if you go to the details from here it will show you the doc up will command is da couple oh bun 2 so I will say da couple boo bun - and you can see it is it will use the latest add by default if you do not provide it and it is now pulling it from the library so it is downloading the image let us just wait for this download to get completed and yes it is done now so let me just clear and if I now say docker images you can see now it is showing us oh bun - and this image was created three weeks ago or was updated three weeks ago and this is the latest egg of course if you want to get the options for docker images command I will again go to docker images and say help and here you can see all these options so let us try this - cue flag so I will say docker images - queue and this gives us only the image ID and nothing else however if I say docker images and we can say - a flag as well so this gives us all the details and this is the ID that we just got here as well okay let me clear the terminal and the other command is docker RMI so before i run this command I will say docker RM I and say docker RM I space - - help and this is to remove one or more images okay so if you want to remove the image you use this command and you can use the - f flag to force removal so if I say docker images - queue to get the image ID which is this one I will copy this and say docker RM I and the image ID and you can see this hey this is now deleted and now if I say docker images I don't have any image okay let us now come to containers so for containers the very first command is docker ES and if I say docker PS space minus minus help to look at the working of this it is used to list the containers and you can say - a to show all the containers and then there are other options like - q is the quite flap so I will say darker darker PS and here as of now I don't have any container so what I can do is I can use the other command docker run to run a container now for example I am using docker run I will say open - now do you remember we have already deleted our Ubuntu image so the Ubuntu image is no longer available on our local system so if I will say docker on Ubuntu what it will say is unable to find the image locally so it will start pulling it from the library which is docker hub and then it will start the container so it is now extracting downloading and extracting so you can say it has downloaded the image and if we say docker PS you can see still we do not have the container running however we have the image but we do not have the container running so in case of Ubuntu what I can do is I can say docker run and I can use the - IP flare so if I go to docker and - - help you can see there should be a flag with - I and this is for interactive and the flag e is for allocating a sudo TTY so what this means in the simple language is we want to start the Ubuntu system ubuntu container and login to it or start the command prompt of ubuntu so I will say docker run - IT for interactive and I can say open - I can say SH or even this should work fine and now you can see we are inside the ubuntu container and we are on the Ubuntu system if I say LS you can see we are now actually inside Obon too so now if I run the command docker PS I should get a container running however I cannot run it here because this is I am here inside open to so I will press command e to go to a new tab on the terminal if you are on Windows you can start a new command prompt and then I will say let me again shorten the name here so I will say docker PS and now you can see the container running and this is the container ID and now you can run the command docker start and stop so docker start and the container ID will start the container docker stop and the container ID will stop the container so now we have stopped if you go back here you can see it has automatically given an exit command and it has come out of that container and it is now on our local system now let us also see very quickly some system commands so one command is docker stats and this gives us the details on the running containers memory usage the input output and so on so let us try to again run our docker container and then just see you run this command I will say docker run - IT open - and we are inside of one - and if I run this command now see you it is already showing us now the memory usage I can again run this command and you can see it is showing the memory the containers the network input output and everything so while you are running your containers and you want to check about the memory usage on your system from docker you can run this command then we have the command called docker system yes so in case you want to check the disk usage of docker you can run this command docker system DF so it will give us the images containers local volumes billed and the size which is being taken by all these darker elements and all the information about the disk usage and then the next last command this docker system tune now be very careful before running this command let me just show you if I say the auger system tune and say - - help so this is this command is used to remove unused data so if you say - a flag it will remove all unused images not just the dangling ones so dangling images means the images which are not associated with the running container now - F is a force flag now be very very very careful let me show you if I say docker system June it is giving me a warning this will remove all stopped containers and all networks not used by at least one container all dangling images that is the images not associated with the running container and alt built cache so let me first say N and let me first show you the images which are there as of now so I will say docker images and you can see we have just an Ubuntu image and if we say docker PS we are in heaven container running from the Ubuntu image so if I will run the command docker system prune and I say yes so you can see total reclaimed spaces 3 bytes and if I run the command docker images my ubuntu image is still there and if I run the command docker PS my container is still running because this container was running and the image was being used so it did not delete them however let me stop the container first so I will just stop the container docker stop and the container ID ok and now I will the command docker system tun and say yes and now if I say docker PS I do not have anything running faster docker PS - eh I do not have any container here as well so the container is deleted and if I said occur images I have the images so if I say docker system prune - a and C it is giving me a warning this will remove all stop containers all networks and all images without at least one container if I say yes you can see it is saying total reclaimed spaces 81 0.15 MB and if I go to docker images you can see the images deleted so be very careful while using this particular command which is docker system prune and these are the top basic and very frequently used commands with docker if you have understanding of these commands it will be very easy for you to work with talkers we will learn more on Dockers in the coming sessions I hope the session was very useful for you thank you for watching [Music] you
Info
Channel: Automation Step by Step
Views: 244,387
Rating: undefined out of 5
Keywords: docker commands, docker basic commands, docker beginner tutorial, docker beginner tutorials, learn docker, docker for beginners, docker how to pull image, docker how to remove image, docker how to remove containers, how to check space taken by docker, how to check docker logs, docker step by step, docker by raghav pal, docker basics, docker how to create container, docker for dummies
Id: HqBMEmoAd1M
Channel Id: undefined
Length: 17min 25sec (1045 seconds)
Published: Mon Jul 02 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.