Introduction to Docker | Docker Installation on Mac | Docker Commands With Examples | Docker Hub

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome back there are two main virtualization technologies one is using virtual machine and the other one is using docker this one is about docker rather an introduction to docker okay so what is docker it is a virtualization technology docker like virtual machines not only allows you to run applications in a separate environment but it does more than that it is one of the key devops technology docker allows you to script entire runtime environment this this file is called docker file essentially docker file contains all the commands to build docker image okay and then you build docker image from the docker file this the command to build docker image is docker build and path of docker file right docker build and password docker file and then run the image in a separate environment called container okay and the command to run the docker image is docker run docker image name okay so our goal in this video is to launch apache web server on docker container and then connect docker container bash shell to modify apache index.xml and see if we get the modified index.html okay i'm using mac so first i'll go through the installation of docker on mac if you're using windows the installation process of docker on windows is little different i will add the url for installing docker and windows okay so once the docker installed and make sure docker daemon is running because a docker is client server based architecture so you have to make sure the docker dimmer is running and then i will pull http docker image which is basically apache web server from docker hub which hosts docker images okay docker default pulls images from the docker hub you can also pull and post docker images uh from other repos beside talker hub for instance you can push and pull images from artifactory okay and you can also create docker images and post to docker hub creating docker image is out of the scope of this video okay and then i will run the docker container from this pulled image and then we'll look uh the result whether index.html is displayed to make sure docker contain is running successfully okay then we'll connect to docker container bash shell then i'll modify index.html file and check the result if i'm getting the modified index.html okay and then we'll see some other docker commands such as listing docker images listing docker containers how to stop docker container how to start docker container and then at the end of this video we will see how to remove docker container and docker images so let's first install docker and mac okay command is if you copy paste the command okay right now it has downloaded docker dmg right um and it is installing cask cask uh takes care of install it's in a ui part of docker for mac okay because docker is a client server architecture so uh on the mac to take care of the server part uh you there is a good ui has been provided by mac so use using that ui you can do a lot of stuff uh for example you can um start docker demo and all there are many other things that you could do so as you can see it is it is progressing and now it says the docker was successfully installed okay now the next thing is that uh we need to make sure that docker demon is running okay to start docker demand i have to go to docker ui for mac okay so let me pull out uh docker ui so as you can see now docker engine is starting means docker daemon is starting okay this is docker ui on mac okay you can see it has so many other options and here this option for uninstall and get support restart so if you need to uninstall uh you just go here on the bug and click on uninstall that so you can uninstall the docker and mac okay now docker engine is running so now next thing is that uh what we'll do uh we will pull the docker http image okay how to pull docker image the command is darker pull and the image name so since we are uh pulling http d image we'll go your httpd the question is that how do i know httpd image you can find all the images on docker hub this is docker hub okay so if i'm looking for say apache web server right i can say here apache okay you can see this is the official image for apache http server okay if you just click here the command to pull this is docker pool httpd okay it's already given here other interesting thing is that uh these are different uh versions of this uh docker file if i just give docker pull httpd then it will pull the latest image okay so it will pull this guy but if i were to give particular version name say if i'm pulling alpine 314 then i'll say docker let me copy this and say then i'll copy this one and i'll say i'll find 3.14 3.14 so that way it will pull alpine 314 image okay but let me let you pull the latest httpd image okay so you can see that it says using default tag latest means if you don't provide any uh version then it default it pulls the the version which has latest tag okay right now the httpd image has been pulled from the docker repository right and this docker hub is the public repository any public image you can find here for many i mean you can find images for example kafka right you can find image for a my sequel right most of the images you can find here there are a lot of images here and if you if you have your own image you build the image and then you can publish on docker provided you need to have a account before publishing your image okay so you can post the image the the term is not published the first actually okay push and pull so right now what we have done we have pull out the http the image and how to list that image say docker uh image command is very simple and say ls so right now uh in our in this my docker environment there is only one image which is httpd and tag is latest and this is image id and created and size okay so now image has been pulled let's run this image right let's run this docker image so how to run this docker image um you say docker run and the image name name is httpd okay see this is running but it i will find it difficult to access the web server so let me close this essentially what i need to i need to provide couple of other invo parameter i will show you what what i'm doing so it's a docker run you say d which means i'll be running this docker container as a daemon right and then i'll say p port mapping 8082 means i'm using this host port and mapping it to containers port 80 and then i will give the image name okay so what this this will run the httpd image right and create container okay and then it will run as a daemon and the port mapping is that uh the container uh port 80 means because it's the web server right so restore will be running on port 80. i want to map the containers um port 80 to hd to 8082 so that i can access the customer from from the chrome browser okay from outside of the container let's run it so you can see there now docker container is started and it has given this this long id okay if you want to see that docker container right now on this on this docker environment you can see that there is one docker container right now and its status is up from 19 seconds and this is port mapping okay now we need to see that uh what is inside that uh docker container right whether web server is running or not i will open a chrome browser and since the port mapping is 8082 i'll say localhost 8082 and see if we got the output from the apache web server running inside container right it works we'll see uh the actual file and then you will know that whether it's giving correct result or not okay what we did actually we pulled the docker image httpd and then we ran the docker uh image now next thing what we'll do actually we will connect to this running container reason is that i gave as a daemon because i wanted to show you how to connect to this uh this container from outside is essentially you will be running as it always the docker demon because it's not a good idea to have it running as a as a without without demand because somebody does control c or your content will be stopped right so it's good idea to run sdma so now since the container is running let's go to container cell for so that we can look the index.xml file and we can modify index.html page okay the question is how to connect okay well the command is docker exec okay and then i t id for interactive mode so what it is command does it creates connection from this terminal to docker std in okay standard interface so and then next is container name container name either i can give this or i can give just id i will give a87 three characters fine because that way it will differentiate uh you don't need to give all characters even if you can give just one character somehow it needs to differentiate that right that which container id i'm talking about since right now there is only one character even if i give just a it's fine because it knows this container i'm running okay let's give 887 typically i give three characters okay docker exec ide container id and next is the actually i have to give bash shell okay let's run it right now i'm at the back shell of the container okay you can do lsu and it is showing the the apache web server directory so go to st docs and get index.html file so you can see that this is output up it works this is this is where you got the output right let's modify this file so that we can see that how can we modify file so in order to modify that first we need what let me do we are index.html okay vi is not found so we need to install vi right the question is how to install vi okay so to install vi first uh what will it do actually it's a little bit tricky uh but uh i have google data already found out so what i'll do i first we need to activate update date it will update the application apt-get is a package manager on the debian side and the red hat linux side you use em right so install we updated aptigate now next is that uh we need to install vi right to install it say apt get install vim this will install vi say yes okay so what is what we did actually right now on my on my this docker container vi is installed so i now i can do index.index.html and i can modify it okay so let me modify it and let me write it something like that say inside docker container okay let's say it works something like that and save it okay so let's go and see whether we are getting the this modified html or not let's refresh it okay spelling is wrong let me change the spelling um okay save it let's go back and see the result okay so we are getting the correct result which is the apache webs are running inside docker container it works okay uh what we did we modified the index.html to see that how can we modify a file inside docker container okay so now next is that we will list images right so let me come out from this guy i'll say exit so right now i'm out of this container so if i want to go back again i can say docker x second and i'll go back again to docker container okay to come out let's exit so right now docker container is running to list a docker image first how many images we have docker image ls so the only one image say you pull another image docker myc docker pull right so this is my sql image i'm pulling out just i will show you that i want to show that docker image ls right so now if i do docker image ls i can see two images listed okay you can also say say if i need to pull kafka image how will i pull just go to docker hub and type here kafka okay so you can see this image name is i think this is a good name but you see it says bitnami's vietnamese kafka means somebody user id is bitnami and and that user with this with that user id this kafka image has been uploaded right so in order to pull it you have to give bitnami slash capcom so let's click here just copy this command and pull this image so same way if if say if i post any image say if i put kafka image on inside uh docker hub then this image name will have sksing slash kafka okay i'm assuming my username user id will be discussing okay so right now it is pulling um kafka image it is pulling latest one right because there is uh no tag is given with colon right so it is pulling the latest kafka image okay now if you list here docker it's fast here okay so we have three images here right and to find out how many containers we have the command is docker container ls so right now there is only one container which is running right let's run another container let's say let's run docker uh run my sequel or kafka um kafka docker run slash kafka okay so you can see this uh just getting say command but ignore it let's do docker container ls and you can see that because there was error this reason you only see still one container running let's run um the other guy mysql see what we get okay it says all this thing you have to give uh password not sorry this this all this thing right so still this list here so still only one of them is running because we did not run it the proper way right to in order to in order to actually run it what the options are so i'll go to docker hub okay for kafka i can find how to run this image by looking into their documentation so what is what it says how to run it so it says that in order to docker pull this file let's see for example if you go further it will give other detail like for example it says okay if you want to run kafka run this way right so they provide all the details how to run a uh image right this one kafka client is it it gives all the deals similarly if you let's go to my sequel and uh okay we don't we'll download this guy i think docker pulled my sequel so if you go down um if you scroll down and here it says how to run it right so you got the idea right so you go to docker up get the image read detail how to run it and you run it right so still we are running only one container which we are fine because our go to was to run web server which we successfully ran okay illustrate container we listed the image okay now next is a how to start in a stop container right so if i want to stop this docker container say docker stop right and container id which is eight seven right so if you see docker continue start right so right now if i go to web server hopefully we will not see any result because right now docker content is stopped right so if you do docker container ls right now it is not listing any container however if you do docker ps nsa it will show you all the containers okay let's start this docker container which is uh docker start and this guy 87 right so start it now if i go back again so refresh you see i got the output again so that this is how you will start and stop docker container okay and say if you want to remove this uh this docker container see docker container rm right and then a87 right uh sorry to continue but it will not stop because reason is right now docker container is already running so before removing it first we need to stop it so you say docker container and stop to pull out the command okay stop it so this will stop docker container now docker container is stopped now if you if i try to remove it it will remove see this this container is gone okay if i do docker container ls okay container is not listed it's gone i'm going to see all the all the processes you see the our 87 is not listed here that is gone okay and what what's going on with the image do it do i still have image or not okay so i still have this image all three images are still here right because i haven't removed any image so let's remove uh say my sequel image you say docker image rm and the name of your image are id i usually use image id but you can use the image name also so let's give 2 fe 3 character is fine because that way i can differentiate which image i'm talking so enable delete an image is being used by stopped container okay so one image could be used in many containers right so um so there is one container which is stopped and it is using that event so i need to first go and remove that container so you say docker either i can remove or i can say just force docker container and say d65 right this guy let's stop it poker container stop once it is stopped d65 sorry not stopped now let's remove this docker container okay so toggle container is removed so let's try to remove the that http the image right or i can give you httpd right just to see that what we're doing okay still there is one more container so there is another container which is using a referenced image what i can do i mean you can play around into it but what i will do i will just use the force command to see how to do force docker image uh this one i say dashed as force okay so now it has removed the http uh the image so if i do docker image ls uh you can see that uh http is gone okay the same way if you want to remove the mysql image you say docker image rm i sequel let's give the name okay so it has deleted and these all the other images which my sql is using right so it will remove all other images as well so you got the idea how to remove the docker image okay you can also remove all containers all image this command will remove all docker container and there is a command to remove all docker images as well you just copy and paste here so this will remove all docker images from your system okay so you got the idea
Info
Channel: KnoDAX
Views: 2,579
Rating: 5 out of 5
Keywords: docker, docker commands with examples, docker exec, docker explained, docker hub, docker installation mac, docker introduction, docker pull image, docker remove container, docker remove image, docker run image, docker start container, docker stop container, docker tutorial, introduction to docker, what is docker
Id: baieX04jB8s
Channel Id: undefined
Length: 20min 13sec (1213 seconds)
Published: Fri Oct 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.