Docker fundamentals: basics, storage, networking - Introduction to Docker (tutorial for beginners)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Oh you hello everyone my name is Ashton Dean and right now we'll take a quick look into the darker and I will introduce you to the darker fundamentals what docker is what and how it differs from traditional virtual machines and so on right after that we will install docker and we will work with docker images and starting the docker containers and we will work with them take a quick look at how to work with persistent storage for docker even know why do you know this and after that we will provide network connection to the containers so how docker differs from the traditional virtual machine and virtualization if you remember and know the virtualization as usual you know that you have your infrastructure storage the computer and so on and you have a host operating system Linux or Windows or anything else you have a hypervisor or just like hyper-v VMware key VM and so on and you install the virtual machines and the virtualization layer will provide motherboard virtualized motherboard CPU memory and so on to the computer and you have to install the guest voices just like Linux Windows and so on and you will install the binaries the libraries the database server and so on and after that you will install the application you want to use so it's a bit complicated sometimes and you can use chef or puppet or anything else to automate this procedures but it has its own overhead so what is the overhead in a traditional virtualization the operating system emulates and the hypervisor emulates the whole machine a virtual machine to the guest OS so you will have a little overhead and the density of the operating systems is limited number of virtual machines are limited so what docker is docker differs from the traditional virtual machine systems that it has single operating system so it's Linux and windows but docker right now only operates on Linux and you have the docker engine and you don't have to install guest operating systems and you don't have to provide virtualized motherboard CPU and so on so this is what we call container virtualization because these are containers and what are in the containers the containers are the library's binary is just like the sequel server just like my sequel PostgreSQL and so on and your own application it has the advantage that you can achieve much more density on a single storage on a single host and it boots much faster because you don't have to emulate the whole hardware just like with the traditional virtualization but it has its own drawback the drawback is that you use the same operating system and the same cabin so you are not able to run Windows applications under darker engine so right now with Ducker you are limited to the Linux system and the Linux applications but it's not so big limitations because it gives you much more advantage over the traditional virtualization in the case of density and docker provides a special format which is very good for you if you're a developer or you are system engineer because you don't have to install your own operating system under the virtual machine you just have to deploy this container this container has a specification the docker specification and if you use a docker image because if work with images and the doctor engine will just extract it just like the traditional just like the raw or a zip application extracts the files from a zip file or other compressed air hives you just pull or deploy a docker container and the docker engine will take care of that and so what does it mean you can package your applications let's say that's your application and my daugher engine is supported you are able to run it so where docker engine is supported and okhla engine is supported on your own system if you install it but it's supported on Asia or Amazon and Google and lots of other cloud vendors and clothes providers so how dr. work with images as you know we have the kernel which is the same for all the applications and we have a beautiful beautiful it's a feature that we've use to provide a virtual file system to the docker images and why we say images because in a docker architecture you always have a base image to provide better storage and you have other layers so these images are put together by the docker using a union file system so you have the base image and you have the binaries and other images and we call them layers so it's a multi-layer image and it has its base image and its other part and if you have this base image it has the advantage that you can use much less space because if 100 container uses this base image you only have to store it once so instead what you have to know about the tradition of virtualization let's say you have base Debian virtual machine and it consumes 1 gigabyte if you run 100 Debian machines it will consume at least 100 gigabytes storage from your system but in the docker architecture because every container use the same base image and these containers are read-only we'll talk about that a bit later it will consume only one gigabyte so if the Debian based image is 1 gigabyte and 100 container use the base image it will only have to store 1 gigabyte so this is a big advantage because the storage is always expensive and if you have to have let's say a match or you have to have an Apache the docker stores them in different images and put these images on top of each other and these are different layers and it will just Union down and these will form a container because this part the stored images part are the docker images and this part is a read-only so you are not able to write anything into the file system but on top of everything the docker will provide you with a rewritable layer and this is where you change your configuration but you have to be there that these containers are ephemeral they are not persistent so this layer is writable layer it's not persistent you have to use volumes or writable you volumes for that and we will use them later but what you have to know is how a container formed so the container formed using the images and docker puts these images or image layers on top of each other and starts the container and put a readwrite table layer on top of that but this is ephemeral as well okay so let's install docker on your system or system is a standard simple Ubuntu and where you find docker if you go to the doctor comm you can download and install it from source or from binaries and or you can use the package manager from Ubuntu but just take a quick look at what we have in the latest Ubuntu system so let's search for darker that IO this is the name of the package under boom - so if you want to stick with the distribution provided version you have to look for that package under ubuntu because in Santo s or open Susie and so on maybe the name of the package differs from dr. die but in a balloon - its dr. tayo so press Enter okay we have it docker IO Linux container one time and show the package type in app cache show dr. dot IO and look for the version the version in a balloon - it's 1.5.0 and by the latest as you see it's 1.7 and as the pace in the changes in docker it's very fast so everything is changing very fast it's better to use the latest docker so how to install it on any Linux system the docker guys have does because they created script what you can reach at HTTP GET dot docker calm go for it and as you see it's a simple shell script and it will look for look for your distribution and install the latest packages so what docker provides you is the binary images the latest images for your Linux system and they have a little help here so how to use it ok we can copy and paste this comment used we get and install it ok and we don't write out this file into file in the file system what we put it on the pipe and provide it to the shell ok go free first it imports their key so they they just sign your packages so you can make sure that nobody touched the images so no hacker or any other intruder were able to modify the package after that it updates the package list and look for the packages and it autumn to install the required packages from their repository and from the Ubuntu repository okay and it gives you some instructions that if you want to modify the docker configuration or you want to provide a user with administrative privileges under docker you can use this command so if you want to provide the diadem a user with darker administrative privileges I have to put the diadem user into the darker group this is what it means okay and just type in ID daca deme and you can see let the diadem user right now part of the docker group so I can do anything without root privileges with docker I can just run docker run containers start containers stop containers and so on okay so what's next next to your search for the images and put images but first we'll take a quick look at how this image storage works under daca okay so as you can see this figure comes from the docker comm as well so this is a very official figure and we will use these comments to pool and run the docker containers and as we talk about the docker images where do you find the images how you get the images you can find them on registries so the registries are the storage for all the images which forms a container and you can use the docker own registry add the docker hub they provided you for free and these registry is public you can set up your own private registry or you can buy a private registry from docker as well but all the images comes from a docker registry so these are the images and when you want to run a container first you have to pull the images which forms the container or you can pull it before you run the container but if you don't pull the images previously when you want to run a container and a container knows what images it has to download the docker subsystem will get the images from the registry ok and the images what you download from the registry are stored on your local system on your local filesystem on your local server this is your docker host or docker server and you store the images here and whenever you just want to form and run a container you will work with the local images and you can update them and you can just pull from time to time later you can just delete the images you're docker host and you can just download it again from the registry so this is how it works that the docker host only stores the required images to form your containers if you don't want to run that container again let's say you just stop and delete this container and you don't want to store the images you can just erase them from your filesystem as well okay where you find the public docker images and the registry there's a site called hub docker comm and this is where you can sign up and you can store your own images later and you can use it for free as long as it's public and we can look for the images and search the registry for specific application so look for WordPress and you can see there are lots of docker images and lots of docker containers for WordPress and you can see how many people downloaded it and how many stars have this is just like how many Margot as a favorite and you can see here when when was the last time when it has been updated so you can bet that WordPress from docker it's very fresh but as you can see lots of other guys packaging docker containers using the WordPress and you can just put my sequel you can see the darker guys package - my sequel as well but there is my sequel container from the my sequel guys as well so you can just choose what you want to download ok it says it's automated build if you use github or bitbucket and you store your own code there you can build app containers from it as well so you can automate the bigger process so in a training we can take a quick look at it and how to use it but right now we just want to use the images you don't have to download the container and the images what a container use from the website we can download it from or Ubuntu server ok how we look for images we will use the darker command and the doctor has search supplement let's say doctor search my sequel ok I will make it a bit bigger and you can see the 10 or a 20 most popular docker containers and who build it if you don't see any other tag here so it's not my sequel or anybody else so it's only stands here - my sequel for a container it means that the docker guys packaged it so you can just search for the base image let's say docker search Ubuntu and you can see there are 1 2 images ok so how to download an image let's say docker pool boom - and it will contact the registry add docker and it will download several images as you can see these are the layers these are different images which forms a container when you start a container so these are the layers ok when the docker put the image it will extract the image layers and the image you are pulling has been verified so it is it means that the system verified that they come from from a secular source and nobody touched it ok as you can see it uses a digest as well and the version you put is the latest so if you just pull anything just like CentOS or anything else always look for the latest so what is ooh the comment the docker pull boom - if I write the semi-colon latest as well that means the same this called the image tag or the container tags so this is a tag and they tagged it with the latest so right now as you can see it's already done it's image up-to-date because without any other tag the docker always pull the latest images but what if you want to download a specific version let's say the latest Ubuntu I know this is the 15.0 for version but I want a long-term support version in my container and this is the 14.04 I have to use the tag okay just to what happens right now okay some layers already existed some images existed but some are very new so right now I have the latest version from Ubuntu and the latest long-term support version from Ubuntu okay what images I have just I will create the screen so what images I have issue the docker images comment okay and I can see that I have one too from the repository and text as these are the latest gets created okay it's almost the same it has to have some differences okay how do I start an image or a container let's run some docker containers docker has a sub command called run and you have to provide some options to it first we will provided with the dash T the T means it will attach absoluto terminal so you can attach to it and you will have a console just like that and we will provide I which means interactive so it will keep under standard input open the standard input file descriptor open and even if you detach from the container you will see what does it mean and okay start a container ubuntu and if we use the Ubuntu latest or you can use a tag so we will run lubuntu 14.04 and i want to use a shell inside it and i want to get inside the container okay this is how I start container and go inside the container in one step okay as you can see the hostname changed this is the name of the container or the hostname those short hostname this is just like UUID or anything else it has been generated and I'm the root user okay so let's see where am I and Who am I okay I'm the root user here as well and if I just type LS space / I can see all all the subdirectories and let's say I want to start top command but as you can see I only have two processes first is the Bosch the second is a top what I just started okay because it runs inside a container right now I'm in a container and if you want to quit the container without stopping it you have to press the control and the P and the Q after that so this sequence control + P and hold down the control and press the Q again and you will get back to the host computer and let's say look for the top process look for the ID okay here's the ID so this is the top top application and you can see the process ID is 12000 142 but I only run this stop inside the container and no other top runs on the system and as you can see it differs from the process ID inside the container because inside the container the applications have a different process ID name space so they cannot mess up with the host system or with other containers they are isolated from each other using the code the namespaces okay and how can I go back I can attach to a container but I don't know what the name of the container okay I know because I had somewhere here but is it generated but if you want to see what docker containers running on your system issue the command docker PS and press enter okay as you can see it has a container ID this is the host name it tells you what image the container uses what command it runs when it has been created and its status okay it's up three minutes and so on and it has specific name if you don't name your container I could start a container providing it with an arbitrary name but if you don't attach a name to the container the doctor will generate name for that container so it's always an adjustment and a name after that so I can attach to it would the sub come and attach doctor touch and I can use the container ID or the name it doesn't matter which one okay I will attach to ecstatic Hoover fun okay and as you can see I'm again here using the top I quit from the top and press ctrl + D so I exited but when you exit this way from an interactive terminal the docker container runs no more so it stops the container and all the changes what you have been made on the readwrite layer has been lost but the container itself is intact and it's here and you can list all the containers even the ones which are not running the docker PS space - eh okay and I can just start ecstatic Hoover again okay and it has been started in the background we have another supplement called docker top okay and who's the docker top tells me what kind of applications runs inside the container and if I shoot the comment docker top ecstatic Hoover I can see it's okay bean bash as we started because that was the comment how I started the container if you remember I created it with the beam - option to run it as the first comment but right now it's running again okay how can you just stop the container it's very easy docker stop right now I will use the container ID okay and it has been stopped okay what's on the system whoa what you have to know more there's a directory under var Lib doc are just change the directory for lip docker and if you list the contents you can see here a containers subdirectory go there and list okay you know this is the long name of the container as you can see the 5v DC and so on is the same 5v DC 8 8 and so on but this is the long guy D change that if you lose this directory you can see there are some configuration files here just like the hostname cut it as you see this is the short ID the so-called short ID it has its own resolve called host and these are the same files what you can found in a running container and it has its all configuration in a JSON format so this is where you find your containers okay and as you can see no binary images are here so because if I start multiply containers using the same base image they will only differ from this configuration and the ephemeral read writable layer so this is why a docker container doesn't consume so much space as a traditional virtual image okay start again a container just change back to my home directory okay Celie and run another version you can see what happens if I don't pull the image previously and just issue the dock around comment let's say I want to wear gym 12.4 0 and start it oh and I just almost forgot to issue the T and I options to that look what's happening it's unable to find image locally and it will start pull all the layers for that and after that it will start a container and I will have another image and it's all happened automatically I don't have to pull it before so you will have your own private registry and lots of host computers lots of docker host and you want to start up container you don't have to manually or some managed way to copy the images to the host because the host will download all the required layers and images to form the new container okay look whether it's running already oh yeah it's not I'm inside the container as well so I just I try to issue the docker PS but as I just told you before it just pulls all the images creates it and just put me inside the container as you see the ball called short name it's a different one and if I just quit it will stop the container as well I just clear the screen okay and if I want to run a docker container without attaching it immediately but later I will want to attach to it I can use the dash D which means it stores the container in detached mode but I have still have to use the zeldo terminal option and the interactive option because if I don't give these options to the container later I will may not be able to login interactively and you can name your container let's say it's duck so instead of the random name I will provide one to that let's say I want to run the boom - and the version 1404 startup in - okay and it's started and if I issue the comment docker PS as you can see right now the name is duck and not random name okay just stop it will its name okay and it's working so as you know the readwrite layer inside the container is ephemeral so everything is lost when you just login or you just stop the container so how can I use a persistent storage you can give a volume to a container and it will be a persistent storage for that okay let's say docker run - T Y and issue the - V just like volume and you have to give a mount point and the docker will create this one point inside the container and it will be writable and when you stop the container the contents will still be there let's say you will not store everything in data slash data let's name it but right now I have to name it duck - because if I just type in only duck the docker will refuse to create it because it's already exist why I could start it with the V option but when I create a new container I have to give a new name to this and I will start Ubuntu 14.04 and be in bash okay right now I'm inside this container just list a subdirectory and there's a data so on a normal linear system you will not see a data subdirectory under the root directory change here go to the data subdirectory and just create some files just let's say touch a touch b touch c touch one to one touch three ok and press ctrl P and Q ok right now I'm in the host computer change to the docker or leap docker subdirectory and there is a volumes subdirectory here go to that subdirectory and list it and as you can see right now here's a directory with a very long name go to this directory and leave the contents Oh as you can see underlined data is here just like or mount point but instead of the slash hits underline and lists and as you can see the file names are the same what I have been created so go back and attach to duck to attach to duck to okay just remove one file let's remove the C and stop the container you know we can just stop the container when you just quit just to be sure issue docker PS and as you can see no images are running so no container is active and if you list the same directory you can see the C is no more here what I have all the files in this sub directory so this is how you create a persistent storage automatically on a docker host so this is an auto-generated directory under the war lip docker volumes but what if you want to attach a specific directory from the host to your container okay just go back to my home directory and let's say create a subdirectory under the SRV let's say it's a duck - and how can I attach this directory to my container I will create another container to demonstrate it docker run - t I - V and I have to provide first the subdirectory from the host what I want to attach to the container okay just use : and let's say I want to use data again but I want to name this container two tap three and use the same room to 14.04 image and we have in bash comment here okay let's say whether I have the data yes I have but nothing inside it change it to it create some files just like before okay I have some files view and exit okay let's see what's inside this directory okay it's duck - but I just named my image two ducks free well okay this can be misleading but it's not a big problem okay and all the three files what I have been created here until this moment we just started containers without any network connection right now we have persistent storage and so on but how do you provide a network connection to your container if you want to expose a port this is how we call it expose a board to open up a port in a container and the container will be able to communicate through this port just download another image let's say docker run - t.i and use the my sequel image and just start it needed edge mode and issue the comment option - P and port 3306 because this is the default my sequel port ok doctor will look for the latest image at the docker hub just download it extracted started and after that we'll take a quick look wherever the port is open or not okay and after everything has been downloaded the doctor just started a new container and this is the long name of the container and issue the docker PS comment oops it not running maybe relax something okay store it with a comment bin bash okay so after that I started the my sequel image with a bin bash and after that it has been started and as you can see the my sequel port has been opened and if I just type in the IP tables - capital L and - T for the table net flow network address translation I can see that the local port this local port 30 2769 will be forwarded to the my sequel port of of some IP and this IP is the IP of my my sequel container okay but no single application will just look for my sequel on that port so I have to have twist the containers okay and it's two against in I have to stop it okay and I want to make sure that the same port is forwarded to my container what I just want to expose so go back to this command docker run detach and open up the locale port 3306 and map it to a container port 3306 this is how I open up a specific port on the whole system and forward it to the container okay shoot the dr. PS command and as you can see everything which comes inside the host to the port 3306 will be forwarded inside a container to the same port and right else to install let's do a guy's thing okay and but what was that IP address this is the internal IP address of my container and how the other computers are able to reach that IP address this is because if I just list all the interfaces on my system with that comment there is a bridge Dockers zero bridge and as you know a bridge will provide Network to the virtual machines just in a case of a VM so it's almost the same you can just open up specific IP address and port connection so I can just let's say I could just if I have this IP address like we just let's say I wanna just want to open up the my secret port only on that IP address so if you have lots of IP addresses you can just expose the ports to the containers and everybody can or everybody will be able to reach that computer so this is how I just expose a port and this is how docker networking works that every container which has networking connections attached to the docker bridge interface and there will be a virtual virtual network controller on the host computer as well it's also generated and its name its auto generating and this is a point-to-point connection so in the host computer you will have this interface which has been attached to the docker 0 bridge and if I attach to to my my sequel server and I just type in IP header show I can see I have general Ethernet connection or a natality interface and this Ethernet interface is linked to this one outside and outside interface linked to the bridge so this is how the computers outside my host reaches the containers and form a network connection with the containers the connections go comes inside and docker bridge before water connection to the virtual interface and it will just forward everything inside container to the internal internal interface so that was all how the networking works in the docker and this is just a basic because we have lots of other options but we will just take a quick look at it another time goodbye you
Info
Channel: Duckademy IT courses
Views: 296,363
Rating: 4.8726115 out of 5
Keywords: tutorial, course, docker, virtualisation, images, container, docker containers, docker container tutorial, persistent storage, storage, docker basics, introduction, install docker, installing docker, linux, open-source, open-source virtualisation, networking, basics, fundamentals, docker introduction, introduction to docker, tutorial for beginners, for beginners, windows, compose, demo, what is docker, docker tutorial, docker tutorial for beginners, swarm, 2018, docker networking
Id: UV3cw4QLJLs
Channel Id: undefined
Length: 53min 27sec (3207 seconds)
Published: Thu Aug 06 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.