Docker tutorial for Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome back aliens monument 7 begin in this video we'll talk about docker the docker is basically an ecosystem where you can create containers where I can run containers but then why do we need it see we can talk about it is docker in detail but then the main question is why do we need Dockers now think about this as a developer or as a tester or as a patient team what we do is we work with Sophos idea ultimate thing is to provide a software so that your user can use it I'm talking about the web application now all web services so what we do is we build an application normally development team they build a software and then this software goes for the testing so testing team will be doing the testing on it all and then after that if everything is going good of course if something goes wrong it it comes back the development team but what if everything is perfect then goes for the operation team so that they can deploy the application on broad server of course depend upon company this process might change but then we have three steps right they look the application there's the application and ship it to the production server so that we can run there one thing is when as a developer when you build an application you might be using some framework so let's say if you're working on Java you might be using Spring Framework maybe you want to build a web application using using Python so you'll be using Django framework so what we do is when when we want to build an application we have a framework and this framework will need certain libraries some dependencies or maybe some O's level features so what we do is when you want to start with the application you need before even before touching the application you have to download dependencies you have to download the libraries now the thing is after researching which library to use after is searching with dependence that you use you will download them and you will have those things on your machine so you have your framework you have your application you have your dependencies and maybe some postal features now everything is done right your product is ready with you and of course the next step would be testing so you will ship this product to the ship to the testing team but the problem is the testing team when they start using the application they might face issues so there is nothing wrong with soft well what went wrong is with the dependencies because the dependency which you have used of course you have list them all the dependencies which are required so they might be downloading those dependencies or maybe you are sending those dependencies in agile file or dinner in a zip file the problem is it's not just the number of dependencies it's also the versions right so maybe you have used our version 4.2 and then they might be using 4.0 so there will be a clash your software will generate issues the problem is with the dependencies and the libraries and sometime you know what happens when you are building an application your application may need some extra dependencies which even you are not aware of so what happens is maybe you have worked on some earlier projects and those projects needed some dependencies which you have in your machine but the same thing is not there in the tester machines my testing team will say hey developer something went wrong something went wrong because of you and you will be saying hey it was working on my machine is not working on your machine so it's something wrong with your machine we can have a blame game there but that's not happen if it happens in the company but then we can you might imagine the scenario right they might be thinking this in the in their head so what if you can when you when you are shipping the application the application which you have built not just application but you have to ship everything the framework dependencies and that is everything so you will take take the entire stub and give it to the testing team but is it possible is it possible to give everything the thing is some dependencies and libraries are dependent on the OS so you have to give the entire OS and that's not practically possible right you find copy or say - haven't give it to someone else and that's where we got a solution and that solution is hypervisor okay if you don't know about hypervisors thinking about virtual machines all VM very few that's very famous software which you might have used in your polish days or in your company so what we do using the virtual machine is so you have a hardware so you have a physical hardware and on that hardware you install an OS of course every app every machine has arose maybe Windows or Linux based OS or Macintosh now all that OS you will be installing a hypervisor OBM well basically now this VMware can install another OS now the amazing thing is when you install the new OS now this OS can be back and you can ship it so you can later so the amazing thing is when you give this always to someone else they can reload it the same oils and this voice will have everything so what I'm saying is Hardwell OS hypervisor and your OS the customers or the other virtual OS now all this virtual OS who can you can do anything you want you can install software you can install dependencies you can you can build an application now when you are giving the application to the testing team don't just give the the software give the entire image of your OS the virtual image which you say and then once they get the image they can create an instance of it so basically you can imagine the concept of classes and objects in Java when you give up class they can create objects they can do it instances of it of course you can't the running image but you can run instances with one image you can have multiple instances running so you can have ten instance if you have hundred instances so that's amazing right so the testing team will they will run the instance now the amazing thing is they don't have to worry about dependencies because you have given them everything the software which you have built libraries dependencies and maybe some oysters features now they will be testing the application not the dependencies but they will test your your logic and everything is working or not and then if everything goes well even they don't have to you know think about the production server they can simply create a virtual image again the new image we making after making some changes and give it to the production now production will have the image they will get the image and the ops team they will simply get an instance everything is running right so if if this software works on your machine it will also work on the server that's great right that's the concept of hypervisors but then something went wrong right because the the title of the video talks about docker in fact in the start of the video I've said hey we will talk about docker and I'm talking about hypervisors so the problem with hypervisor is it's a great concept right so if hypervisor was perfect we don't even need Dockers but the thing is hyper wise I still agreed ok there are lot of application there a lot of companies they're still using hypervisors for various reasons but for one of the reason why hypervisor is not preferred is the the thing is when you install an OS ok then you install the hypervisors and then you have to install another OS now what if you have a server and then you want to learn multiple application so imagine every application will need its own OS not that will be bulky right so you are basically running multiple operating system on the same hardware the same physical hardware so you're wasting resources okay when I study socia wasting CPU you're wasting Ram you are wasting harddrive you are wasting all the resources this the next issue is with the licenses what if the OS which are using is Windows OS so of course you have to buy those licenses or even if you are using a proprietary index based OS you have to buy licenses for license for that so we don't want to invest at of that much of money so we got a concept of containers no thanks to Linux containers which is lxv we can have a container systems now what continuous are is think about containers as hypervisors the only differences in containers we don't install Newars so all the containers will share the same they will share the same OS cardinal that's beauty right so on the hardware you will be having OS on that noise will be installing docker not hypervisor docker and on this docker you can have multiple containers and each container can run its own application the full-fledged application your application dependencies everything that that's awesome like so that's the concept of containers now this container can be created with the help of images now go back to the example as a developer you will be having a physical hardware on that hardware you will be installing an OS on that OS will be installing docker and on docker you can create containers now once you build into the application you just have to pack the application that you have to pack the container now when you pack a container it will create a image now this image goes to the tester they can create multiple containers they can create multiple instances and each is just we can call it as containers again the same concept imagine image as as a class and if you have multiple containers as objects and if you create two container of the same image they will behave in the same way okay because they are the containers there are these juices of the same image so now when testing team has this they can again they can do testing and then when this ship when this ship this product to the production server again they will again give the image and on the person's away you can do in containers and container will have everything they just need a docker system there and it can run the application now the beauty is you can create your own container so let's say if I want to teach framework to someone and then or maybe I want to demonstrate some tool so of course they don't have to install all this office so what I can do is on my machine I will install docker and I can create container with multiple libraries and Spring Framework and then I can give them the container the image now they can run the image on their machine on their taco right so we can also share the images and that's why if you go to the public repository of docker they will have all the they have most of the repositories they have most of the images so you can use those images example they have image for for readies they have image for Noah so they have image for the window as well so if you want to run those application just use docker pull the image run it on your machine and you can you can get started right that's the beauties the beauty now come back coming back darker and darker is a ecosystem as I mentioned in docker we have so many things to talk about we can talk about chocolate hubs so the deposit we just talked about talking about it was a docker hub then we have a concept of docker engine so you know we have a client-server architecture where we have a server when we have a client of course we can talk talk about those things in detail it's not a small topic to talk about right so it has so many things involved inside docker so docker is also a company now when you say you work with docker so that's a company they have talking in fact doctor also has a enterprise version so they have a community version the Enterprise version committee was is open source and they have named it mobi and that the enterprise version as well the feature is almost same is just that for the enterprise version they provide support [Applause] how to install docker on Ubuntu in fact these similar steps are available for different energy distribution you can use it for Debian or different OS now open to is one of the famous distribution so we are going for it and one of my personal favorite in fact if you want to install docker on Windows or Mac you have to go for the desktop version of docker of course we will see that on the website so what we will do is we'll go to the official website of docker first so let's jump back here and search for docker calm and this is the website in fact I was supposed to search on the address bar but I don't know what what happened here so I will just go to this website and this is the official website of docker and you can see in fact in the first video we have talked about it when you are working on your application you should not be thinking about the environment you should focus more on the application and that's why it says debug your app not your environment that's fine right so in fact docker has multiple components one of the most important component of docker is docker hub where you can get the existing images in fact there's so many images I've been able you can just use them and we'll see how to use the existing images now if you are using Windows or Mac you have to go for the docker desktop for Linux it that is suppose docker because docker was built on Linux and they have it as containers thankfully in Windows 10 also we can use the containers for Windows which is Windows containers unfortunately for Mac it works on Mac ok but the only thing is Mac will have a virtual layer for the Linux so indirectly your dacha is working on Linux which is working on Mac so that's why I prefer to work on the ducts then Mac wait come to docker but yes it also works on Mac so let's a get started so to be Kate a docker download here doesn't matter now how do you download the doctor online up so in fact before installation I want to show you one more thing what if you want to experiment with docker without without installing on your machine maybe some time your machine is slow or maybe you want to just experiment you don't want to install it so one way of doing that is by using a tool called a play with talker so if you go to this website which is labs dot play with docker comm in fact if you search on google it will be the first link so they have an option of playing with docker online so they have this entire tool you can just go there and you can type the top commands it will work initially when you go to the website they will ask to login I have already logged in that's why it is not showing log an option so I will click on start and it will create a playground for me or the design box environment for me now what is happening here is the thing is due to the log down the internet is getting very busy every ways working from home that's why the integer is not that perfect in this area so I will just that was there there are some issues so once you once you go here you just have to click on the new instance ID it will give you a setup for us and of course I can experiment there this is the what you say a prompt and this is where you have to type the commands now without the command I will check here is darker version if this is working so there's no coercion when I say enter as you can see we caught the version number so they are using the latest version which is nineteen point three so 19 is actually Dhaka is going with a version similar to what open two does they go with the major version as the ER so this is to the 19 and they are going for this the minor version is of the month and they have to patch I guess they are not using the latest version for the for the online I guess it is 8 which is the latest one so we'll see that once we install docker on the local machine so yes you can experiment with this in fact everything almost everything works here they are by default providing here with the Alpine Lynott's so you can you can experiment with it but then if we don't want to use it here right we want to use it on off with on the on the physical machine on this machine so let me just close this and of course you can do some experiment let me just close this and let's go back to this website but I want to install docker on on the next site so for that I will go to this website which is the first one the docker calm so this docks calm and they have the choice of steps in fact they also have some documentation if you want to read so version of Ubuntu I'm using so I'm using this one 19 point 10 which is the Aeon version it also works on Bionic so if you're using Bionic now that's fine okay so how do you follow these steps in fact there are multiple ways of installing open in showing darker door number two there's a way of installing it with their property posit Ori there's a way of installing it with from the package with that there from the package or the easiest way is using a script which we are going to use in this video but before that I want to show you some more things what what happens is you know sometimes in your machine you might be having docker pre-installed may be for if you have done some projects before and then it has installed dock on your machine you don't even know about it so make sure that you remove the older version so that it will not conflict with the new version and this is a command to do that so let me show you show the command here so this is a command just just copy this so go back to your terminal and this is where you will paste that command so I will say paste o before that I just want to check though we have dock install on this machine so the way you can check that is by saying docker - - version and if you can see in this machine I don't have doctor installed it was actually installed before but for the video having uninstalled it so there's no dock wise up now I want to just for the experiments sake how we'll just do that and enter so it is saying there is no docker engine or doctor installed on this machine so of course nothing is there now once you know that these no earlier was time to install the fresh one as I mentioned you can use the latest you can use the repository way you can use the package way but we will be using the script so just go down and this is the script we have to use in fact there are two ways of doing it either basically there - or scripts one will give you this table one and one will give you the the test testing version of docker so if you use the kake.com it will give you the latest one or stable one and if you say test.com it will give you the testing version of talker so what this script gives you so if you go to this gate so if you go to this website which is ghetto calm it will give you a script you just have to run this script on your machine now you'll be thinking hey I just have to copy this and paste on terminal not exactly this is a script so you can use shell script to you to run this how do you get this script on your machine it's very very easy if you just go down there these steps for that so you can see you can use curl to get that script so I will just copy this go back to the terminal and save paste now this will get this will give you a script in your machine so if you can just go to your home folder you will get a file which is get docker dot as such which is the same script which you have here I know if you can see this script doesn't matter so it will check whether your system is it 0.2 then which version of Ubuntu you are using and they also have in fact they will download the repository from this website so this is this is where it will go it will download the repository for you so it will search for Linux and Indian actually have different OS available so it will go to 0.2 that's what it is mentioned in this script so you do not worry about that in this it depends upon which one you are using so I'm using Eon so it will check for the release and it will install docker but then I know we are waiting they are waiting from a long time to install let's directly get to it now once you've got this prepped it's time to install docker so you just have to run this script which is SH get dock or not SH say paste it might take some time depend upon your system speed network speed and luckily I don't have that network speed today so it might take some time okay that's done so you can see we have darker on this machine so you can see it has it has done lot of work for us this script actually so it is downloading do you want to version if you remember this the same website we went we went for and it has also that's the version which we are using so we are using nineteen point three point eight this is an issue not the that not the version which is there with the play with docker so we're using the patch version of gate which is 2019 March patch 8 and what else that's our version which is doc engine in fact we'll talk about this in detail data what is what is flying on the server and what happened what is daemon and how it fetches the data from the server dress-up now you can see we got the dock installed and now it's time in fact it is telling you one more important thing which is so it says if you would like to use docker as a non root user which most of the time we do you should now consider adding your user to a docker group with something like bypassing this command not a compulsion but if you are a non Yunnan root user most often times we are and if you want to have the privileges just let's do this so it's a pseudo user mode AG docker and your username I use anymore for this machine the account is Naveen and done I am a user so now I have the permission to learn the container any way I can I'm also the admin server doesn't matter actually so so we got to dock on this machine and how do we test it it's very easy you can just simply say doc oh version and your job is done you can see the contour version there so what happens you know the moment you install some software B or the programming language let's say if you install Java or Python the first thing we do is we run the first command which is hello world right if we thought all the world you are not sure what is happening so let's run the hello world in fact docker provides you a image off in a world so whatever we do is I will say docker run hello world let's see if this works so it is doing something so it says unable to find the image hello world latest locally or is it is it the error but not exactly so just wait for some time it is taking some time to download okay that's done so we got the hello world and if you can see here we got a message which is hello boy so hello from docker so this is the message which you got from the intent but what what is what happened we had seen and that is what is mentioned here since elation when you when you want to use docker docker will have a container right so now you've got a container in your machine do you want to check which container soft I'm talking about so PS a so you can see we got a container so container is container has stopped because it has done its work but then if you say if you see here let you just stretch this a bit if you can see we were we had a container here which is hello void image and this was a command to use it this was the container ID so this was a container which ran and it has given you the output but then in this machine when you install docker for the first time you will not be having this container by container with you not a local copy and that was the error here it says anybody to find in the image hello world in this local machine so if you don't have this image on this machine it will search the image on the depository now which repository so we have this amazing repository here which is hub dot docker calm so if you can just go here this is the repository where you will get most of the containers so they have lot of containers available here yes I mean not just for hello world some meaningful containers as well like like for node for Ubuntu for readies I mean just name it so if you can search for word hello boiled container so that's the container which we have used you can see it is very popular it has more than 10 million downloads so this is a container which we have used actually so it can see it's a dock of docket official images so basically that multiple images somewhat official some are in fact you can also create your own image and you can deploy it so anyway it is officially it will say official image so this is what we caught right so when we ran the docker hello world we call this message so what happens is so when you hit the when you search for the command when you say run hello while it will search on your machine it is not available it will go to the docker hub and it will download the image and then once you got the image it will create a container so you can see it says docker demon create a new container from the image and with one image you can create multiple contain and not just one image you can have multiple images from the repository and you can create containers of it okay so every image will have different containers and once you've got the image from the from the repository your server will send the output to the client so the same machine you will be having the docket line so your terminal is actually talking to the dock a blind doctor is talking to the doctor daemon which is our behind the scene in the same machine and then which is talking in the Attic to the server to the top rocketHub and that's how you got the output this is the doctor hub which we are using here but what if you are doing this summer the same command the second time now when you say run the second time you can see we have not got that message which is unable to find the container or unable to find unable to find the hello world image because it is already in the machine now right so it will simply run that container it will be quick for the second time and third time for the first time it will take some time to download so that's how you install docker on Ubuntu and we'll also see how to install the curt on Windows later so that's it from this video I hope you enjoyed let me in the comments section and users come for the videos bye bye welcome back taylean my name is 720 and in this video we'll see how to install docker on windows so we have seen how do we use docker on Ubuntu in fact we have seen the installation of it and then we were also able to run the hello world but now it's important to understand can we do the same thing in Windows and is it different from Lena so let's let's explore that now the first thing I will do is of course we are on the website of docker and we will see how do you download but then let's go back to command prompt here like we need to see do we have docker installed now how do we check that so it's very simple you simply have to come perform this operation or you say doc of version now if it is giving you the version that's great you have a doc on install but unfortunately on my machine we don't have a docker so let's install it now for that you need to go to your daughter website and you in fact you can just finish off searching here of we'll get that but then we can just go to Google and search for docker download or unfortunately I'm on bing I mean that's weird anyway so if you go to this website which is hub docker calm David they have an option of downloading the docker desktop for Windows now we have seen this website before right so when we were working with Linux how we were installing the docker there we have seen what is hot dogger calm so they also have the desktop version of docker on this website now this desktop version is available for Windows and I guess Mac as well so here what we'll do is we can get the two type of setup one is stable one which is preferred now if you want to do some experiment you want some experimental features you can go for the edge one as well so let's stick to this table one let's click on get stable so if you check the Downloads it is downloading the setup but the good thing is I already have this set up on my machine so let me just show you that set up here so you can see I already have a set up here let's click on install now this is one of the easiest way of installing software unlike Ubuntu where we have to you know in the winter we have to come past commands and something but here we can simply double click here now the only thing is you to have the hyper-v feature enabled so if your it is not enabled you can just go to Google and search for how do you enable hyper-v options on Windows and I guess it is only available in Windows 10 Pro so normally I don't work on Windows much but then do check that if we don't have hyper-v option in Windows that means you have the other versions of Windows 10 which is I guess home if I'm not wrong but then yeah so paint probe we have it so in this machine I do have windows flow so yes I want to enable the hyper-v options and I also want to add the shortcuts so let's click on ok so it may take some time depending on your machine speed so you can see we have done with the installation click on close now it might ask you to restart your machine so if it is asking you to restart please restart your machine ok so how do you verify now so it says installed so do check for the wheel icons just go to your system tray and check for the way like and if it is there it will say it is starting the docker and something so you can just take that check out so if I go to my system tray docker is still not here so what to do now so it's time to restart the machine okay so once we have restarted the machine let's go to the system tray to see how the icon looks like so you can see we have a wheel icon here and if you click on that that's a docker so it says dock is still running so when you get a restart option that means docker is running you can check about the about docker and will see this we can also go to - but and stuff but if you go back to settings this is very interesting so you can jump to this source and you can add just the amount of resources you want to allocate to the docker so in this case it will go for some by default options so as a big now stick to the basics stick to the default options so let me just close that now with this docker when you start the machine it will also give you a prompt offer tutorial for talkers so you can just follow that and can understand how darker works but then we are also seeing that in the video itself right so how do you verify it so one one of this step is you can just say doctor version the same thing we have checked before the inside of the video and so yeah that's the version we caught so we call doc operation nineteen point zero three that's a stable one so this is working now one of the way you can check also download the image you can run it so the same thing we did in the Linux tutorial as well so whatever you do is I will go I will say taco and I want to run a hello void image here so I will say hello boy and it should work so if I say enter now initially when you do this for the first time it will say the docker the image for hello world is not available that's the first line it was saying unable to find and then it will download these image from the hub dot docker calm now just to explore that I can just go back to my browser I normally don't prefer to use edge but wait for videos it works so I will say dot docker calm and the amazing thing is this edge browser is based on chromium so you always get the feel of chrome when you use edge okay so here we are actually working with this HelloWorld image so if you can just go there that's the official image which we have and this is what we have downloaded in this in the in the local machine and that's the thing we got we got hello from docker right so this is how you install docker on your local machine on windows-based basically so now we know how to work with Linux we know how to work with Windows so I hope you enjoy it let me in the comment section and doose's cover for the videos bye welcome back aliens my name is ivan ready and in this video we'll see how to use docker ubuntu image in fact before that in the last year we have talked about how to run a hello world container so we have pull the image from the depository and then we were able to run that on this machine using a container of course now i want to check how many containers are still running in this machine so if I say docker PS you can see there is no container running but yes you know I was doing some experiment before the video so I have created some containers and they ran and then the job is done but now I also want to know since there is no container running is there any image available on this machine so if I say docker images then this is one of the command using which you can get all the images or you can say docker image LS this was all these the images we have so in this machine I have two images yes in the last video we have we used hello world but then with my experiments I also got two one two of course you can remove this and that's one of the purpose why I had that image there so I if I want to remove remove the image it's very simple you can simply say talker and the command you can use to remove image is RMI to remove a container we simply say RM and to remove the image we say RM i and then you have to mention the ID or the name of the image in this case let me use an ID just to see if this works perfectly so we'll just copy this and paste it here and it see it says there's either it says the image is being used by a stopped container okay so I have to first remove all the container know this is important so if you want to put your remove a particular image from the from the system you have to make sure that there is no container which is still in a running or a stopped stage you have to destroy the container first now how do you remove a container it's very simple as I mentioned before you have to say docker rmn you have to mention the idea of the name both works so I will remove that particular container so which one is for the Ubuntu so you can see how I work with multiple Ubuntu containers here and this R existed I guess this two are there which are still just running you can see we have a container is running with this thing so I will simply say copy paste enter and you can see it is removed still the container is containers are still running you can see they're asking us to remove this one so even that is removed now if I try to remove the particular image okay still used by see this one so to remove all that we just pause the video let me remove all the images now as you can see once I deleted all the containers now I can remove the image now once again if I say image LS and you can see we have only one image but now I want to work with Ubuntu now how do you get I went to container here now in order to do that you have to first say docker and you have to mention the image you want to pull the image so you can say docker image pull of course you can't I click on this but then that we can do it in two steps here first we'll pull the image and then we can run the image or you can go with the older way you can simply run the Ubuntu it will it will check do you have the version or do you have the image in the system otherwise it will download from the from the docker hub now here I will say pull and then we have to mention the software which is Ubuntu and you have to also mention the tag now this tag is latest so if what what if you don't want the latest one you can also specify the version you want download so if you don't specify anything here it will go for the latest one that's how docker is probably hunt so I will simply say ladies one day dish one it's better to specify and if I say enter you can see it is downloading the image from the hub and it will take some time because it's bit bulky but if you observe and I say bulky look at the size of the image it says it is 26.69 MB now that's that's amazing right because in this machine as well I have a point two OS and then when I download the ubuntu it was around 1 GB and the image which you are getting now which is of 0.2 is around 26 MB what's what's going wrong there why it is so lightweight the thing is the version which you are getting from the docker hub has limited set of features the features which are very important so it will give you the minimal version of Ubuntu now what what does I mean by that now first let me just run this container and then we will see what I what I mean by minimal container now how do you run this container so first of all you can run the container is ok so let me just list the image first do you have so yeah we have 0.2 and we have in a world now I want to run this image right so the way you can do that is by saying docker you can search one now when I run this code I also want to make sure that the current terminal becomes the console or become the terminal for the ubuntu container which we are using and for that you have to use ID and then you have to specify the image name so otherwise in fact you can also mention the image ID that's better so we are saying docker run - I T the image ID and then you have to also mention which command you want to execute so say I want to execute the bash so if I say enter you can see we are navigated to the prompt which is the Ubuntu prompt so now we are not using Ubuntu off of the host OS or the host ubuntu we are using the ubuntu from the container now in this we can perform lot of operations which you do on Ubuntu or Linux in fact you can perform the first operation let's say you want to check how many processes are running so you can say PS so by default there only to process which is bash and PS PS because we have ran it and bash is because we are using that thing here okay that's one you can also lease the directory so you can see we are saying record all the dike trees here what does we can do here in fact you can also check the system information so I can say your name a and one thing is important the Cardinal version which we are using here is 5.3 that's great upgraded version and that's that's the next version you can also run who am I so all these command works right so you can see it's a root user okay but then what if I try to ping google.com here what if I want try to ping that is calm here though me just say enter you can see it says ping command not found on that sphere ping is not the very famous command I using which you can check your interconnection right or this server is running or not but then it says ping is not available the thing is the Ubuntu which you've got in a container has limited set of features which are very important for the projects and then it doesn't have features which are not frequently used like ping because we don't use ping on dock Assad or the other servers right so here's ping on a client side that makes much more sense right but then what if you want to use ping in your container is it there's a possibility that you can download this see now this will this thing makes sense not forward to container but what if you are using a container or an image which provides a limited set of features and you want to add so really talk and allow you to do that of course right once you're inside 1 2 you can download whatever you want what if I want to install it so we can install that with your power so first I will say get update let me update this Ubuntu ok now once the update is done let me just install the ping command so I will say apt-get install and you can say IP utils - ping now once you do that you can see it is downloading the ping utility ok done let me just check ping now does it work are you getting any response from the discard com let me check oh yeah so just working you can see that ping is working here that's awesome so you can install whatever command you want to in this system so that worked but then what if you want to use this one to container multiple times or different machines now this is the container which the image which you've got from the repository doesn't have ping right what if you want it to be there so of course you can't update the existing image but then you can create a new image so you can pack this container create a new image and push that on the docker hub so that other people can use it and you can also use it so yeah that's how that's how we use Ubuntu image of course you can run multiple commands here try it out let me know in the comment section what you have tried so that's it from this video where we have seen how to use Ubuntu image on docker and how to install some more commands so I hope you enjoyed subscribe the channel so that you will get more updates on this channel welcome back aliens monument 70 idea in this video we'll talk about docker architecture in fact we have talked about which is docker we have seen how to install it or how to pull images from the repository and then if we were able to run the containers as well but then now it's time to understand what is happening behind the scene and then the best way to understand that is by understanding the architecture now in this architecture the first thing I talk about is the way docker was made so initially docker was made as a monolithic application which means one package or one thing will have everything but then Daka is really famous in the world of micro services where you create multiple services right and the wide open is mono thing now docker has a lot of components and each component has a special work to do right so now if you talk about the main component of docker is darker engine and if you talk about docker engine we have certain parts there now the software which you have installed on your machine you can quite as docker engine so the things we have in docker is we have a docker depository which is on the remote server and now we are not responsible to manage that right we are responsible to manage our machine our dog our sister and that sort of engine now this docker engine if you look at that diagram we have three sections here the first one is a client now when a user sends the request the request goes to the client now the terminal which we have worked on or so that interacts with Our client which is a talker CLI basically and now this request now what L command you pass let's say if you want to pass a command for run if you want to pass a command for pull the image or delete image or they move the image now all this thing goes to this server now we can purchase a docker demon or in charge we can call it doc ID that's very famous right so we have dr. daemon who will do the work for you but then how a client will interact with the server are they on the same machine and the answer is yes if that system which we have worked on the client and the server was on the same machines and the waiting in track is with your published API this server or the demon will have lot of endpoints and then for different work we have to have different endpoints so the client will send the request to the to the docker demon now using this you can manage your volumes you can manage your containers you can manage your images now there is one thing important about volumes which we are going to talk about later but then remember one thing as a container container can run your application plus container can also store data but then if you talk about volumes in fact ball you can also store data but we'll talk about that in sometime if you focus on the actual architecture of docker it looks something like this we have a client now this client will pass commands right so you can pass any commands you want of course the command which is accepted by the docker then we have a docker host now docker host has this amazing service called as docker demon but this demon is responsible to accept the commands from the client and perform the operation operations like managing your container it will get a container for you it will manage the images now if you focus on this docker demon the question is can it really create containers for you and the answer is No see as I talked about we have lot of different services for different work right so if docker demon gets a request for the container the request goes to the container deed now container it is a special service which is responsible to manage the lifecycle of your container okay that means the container can be created or run by 20 Noddy not exactly this actual work is done by run see now run see is a special service who is responsible to create containers for you it will simply create a container and this job is done it will go out that means if you wanted multiple containers if you want to run five containers you need five Lansing that's not the case with container D just one in one machine now question arise from where you will get all these images and that for that of course for the ad we have a depository or to be specific is called as the discrete the famous one is dock at her but then they're different options available as well now coming back to the container see as a as an application when you when you run the application that will be done that we'll be learning inside a container and your application want to store some data now container itself provides you some writable files and you can use them so you can create files and you can save it on the container but the problem is once you destroy the container you will use the data as well see you can you can save data in the container when you stop the container data is still there when you come back in the resume state the cut the data is still there but what if you stop and when you destroy the container you will lose the data I want to piss off the data and that's how you that's where you use volumes also using volumes you can store your data but there's one thing important if you want to store data in containers we have defense to this drivers basically a one of the famous driver which we are going to use is overlay two there are other terms of an available as well which are a bit old and which are bit outdated button over there too is awesome now one thing is important to remember in fact we have talked about that in the previous video as well if we talk about the docker host we have lot of images right and with one image you can create multiple containers okay so you can have maybe thousands of containers running and we can have multiple images but for one image you can get multiple containers that's something you remember so that's it from this video I hope you enjoyed it means let me know in the comment section and this is coming for further videos welcome back aliens my name is Devin trivia in this video we'll see how to create a django application on docker so we have talked about docker then we have seen how to install it but it's important for us to understand how to build an application using docker see there are two ways of having your application running on docker first we can create a project separately and then we can dock arise it or we can say we can continue lies the application so that it will run on docker the other way is you can create the application inside the container itself I mean you can install the dock or you can install the Django framework on docker and then you can write a code so by default you are going with that way of writing your application on docker so the moment you done this application it will directly run on docker container so we are going for the second way in this video of course we have to also understand how do we contain the existing applications which we are going to see in the next video so in this video we are trying to create a django application on da course of course on this machine you need a docker installed so it is verified do we have dock install so if I go to terminal and if I search for docker version and yes there's a door installed I just need to create a Django project here and of course we are going to write a simple hello voyage application we're not going to do something big here because see if you and if you know how Django works of course once you have seen once you see this video you understand how to get a big application on docker or you can just google it out how to a database not on different stuff but here the important thing is how can you build the application now if you're not sure how to write a django application and what is django i have a series on django available so in the description area you will find a link for the django series django is basically a web framework for python so of course you can build web application using multiple languages we have java we have a dotnet framework we have PHP we have Python and if you want to build your web application using Python one of the best framework is is Django so let's let's start with this now first of all let me create a folder and yes we are going to use an IDE here which is on the editor here which is vs code so you need vs / as well of course you can use any idea which you prefer but if you want to follow along vs what is preferred one so that you will not get you will not get stuck anywhere so let me create a folder here so I will say mkdir and I will say this is projects and let me just switch to projects switch to projects here and in this project I want to create a Django application but then I want to put that in a separate folder so I will have that folder name as the risk oh of course it can have an Indian doesn't matter and let me switch to the disco here and let me create a project but then even before creating a Django project you need to do some setup on docker remember we have we are building this Django application on darker so we have to write some configuration files for docker now on docker we have different options for configuration one of the best configuration files for docker is docker file itself so what so what is docker file so docker file is a configuration file which helps your doc engine create a containers for you so based on the image so as we have discussed before we have images and with those images we create containers now in this image what features you need so what are the layers you need we mentioned that in the docker file but what happens you know when you are working on the big application when you work on the enterprise application you don't have one container running you might be having multiple containers and to configure all these containers you know at what time you want which container to get started you can use a special feature of docker which is talker compose so we are going to use docker compose here as well I mean if you want to use this application if you also go on to work with database then docker compose makes much more sense so we will start with that so let's use docker compose button if you want to configure double compose you need to create a file so I will go to my vs code and the folder which we have play let's open that here so I will go back to be asked or I will say open folder so I'm in my projects folder where we have then his Co let's select that and click on ok so I'm in this folder where we have that is Co let me just close this and here so this is my folder where I have to create a darker composed configuration file now what format it supports so normally we can go with Jason or they can go with DML so let's go with the AMA which is sophisticated Jason so let's do that so the file name has to be darker - compose and the extension we are going to use is why I mean of course you can also go for the for later exchange which is why am L but the environment makes sense now once you've got this Vimal file you have to write a quantification here but then it will write the docker compose confucian data and usually let's go with this single container configuration which is talk of file let me also create one more point efficient file this is for docker specifically so which is docker file and remember to have this name as the capital that's important D capital and it's a one word well F is small there is no extension for this click on enter so we got two files here which is docker compose and docker file now in this docker file we have to write some steps now you can just go to Google and search for how docker file works and how to do that so in this video I will give you some steps of creating this application so my vs code says the dopper extension is recommended for this type so yes it is helpful for you to have this exchange ins in your machine so I got the doc docx extensions as well so it it makes you a project easy and manage and deeper containers application so of course it will give you suggestions and it will let you know what went wrong anywhere okay so here what I will do here is first of all I have to mention C but when you talk about images in docker it is created with the help of layers so one image will be having multiple layers so we have to start with the base layer so this project is built on what so this project is built on Python so what I will do I will say from so we have to mention the base image and the base image for me is Python and the version we are going for is 3 then we have to mention the environment variables so let's say that first Python unbuffered then we have to create a folder so normally when you run your application the container it's it's good to have all your files in that particular folder so let me create a folder here and then the command I want to execute is mkdir in the container and for that we have to use this run command and the internal command D the UNIX command you're going to use is mkdir and remember I am doing this practical on Linux based system so the container which we are going to use is layers based of course so I want to create this inside the app folders of course it can have any name so let me just have it app and then I have to switch I have to mention my working directory so where I want all these files to be I want it to be app now the next thing would be so let's say we are using docker to run Jango but then we have to install Jango on the on the server right we don't have Jango as of now so we have to install Jango how do we do that now if you have seen my Jango series we have to install the Django admin on the system so here as well in this container we have to install Django admin but how do we do that so the one way you can do that is by creating a separate file and the file we have to create is called requirements dot txt of course you can have a name so it may have this file name as requirements dot txt this is where I will mention what requirements I have say in your project you might be having multiple requirements maybe you have a requirement for mask you'll you may be or you come in for Django so here we have to mention all these things here so we have to say Django we need Django and the version we are going to use is 2.2 so we can use double equal to or you can also specify relative operators which is less than or greater than if you want to specify the version which you're going to use so that's one we only need Django and to include that here we have to inform our Django application hey we have so if you have please instruct our doc of that we have to install Django and the way you can do that is by using copy so we have to copy this requirement file in our projects I will say requirement dot txt we have to push that in our folder which is app okay that's done now once you have seen the main thing is in your container you'll be having this app folder now this app will have your source code your requirement txt I know this will not have your source code but this will have a requirement dot txt now once you have requirements dot txt inside your app you need to install the requirements so you have to again run a command but this time you have to execute the installment commands right so if you want to install something we use PHP IP maybe you if you don't have P I opinion container most it will have P IP based on which type of Unix you are using if you if you are specifically focusing on alpine I'm not sure do we mine has B IP but I guess by default will use Ubuntu so ap IP will be there if you get errors with this VIP install make sure that you also installed p IP okay so in your in one of the command Ron you have to also install p IP but i'm assuming that it will have VIP service apip install all and then i have to mention the file name refugees requirement dot txt now this will install all the requirements which is mentioned in the requirement story extreme now once you have that you have to copy the entire project and tap folder which you are creating in the or in your base code into the app the app which we have mentioned here so basically this app will have the entire project in the container that's a tag that's a docker file we caught an error here that should be capital ok so now once we have reached till this point it's time to move to our docker compose so yes we have done with the commands dot txt we have talked about docker file let's move to top of compose now in docker compose we have to mentioned different steps maybe you want to work with database maybe you want to run these on this server so you have to mention all those configuration here so this will simply follow the steps you know this is a main file which will start your containers which will link your containers and so forth so first of all let me mention the version before you're docker compose we'll say three and then we have to mention all these services which you want to learn so do you want to run a web service do you want to run a database service now in this example I just want to focus on the web service so what I will do is I will mention all these services so I just want to run one web service I will say web : and in this web I have to first mention what to build so I will build the current folder so when you say dot it will build the current folder if you have this in some other folder you have to mention this entire path now once you have your bill to ready of course you want to run your Django application right now when you run your Django application you have to mention the host port numbers see what happens is when you I mean when you request this from the browser browser is external to your container right so browser will talk to the host machine and host machine will have its own network system your container will have its own network system so you have to mention that you want to accept the request from all the hosts from anywhere for that I will say command and then we say Python you have too many you have to run your server remember when you work with Django this is a command you have to pass python manager py runs up but with this you have to also mention the IP and the port number well from where you want to access so I want to access from everywhere so it says 0 0 0 I mean 0.0.0.0 cozen 8000 now that's the port number I am using you can use any port number doesn't matter the next thing you have to mention is volumes I mean when you when you when you run your application on docker it will have a container now inside your container you can write data the only problem is continue will lose data once you destroy the container so what if you want to store some data from for a long time and that's where we will use volumes so you can also mention volumes of course we are not going to use volumes in this code but maybe if you want so you can mention volumes so the volumes I want to put inside app now which port I want to expose I want to use port numbers 8,000 colon 8,000 and that's it once you have mentioned this your web service is ready to use but will this really work that's a question so this point nowhere we have actually created a django application we are simply doing all the configuration now once you have done with the configuration it's time to create your Django project but how do we do that it's actually very simple you just need to move to your command line or Vaser terminal so we go to terminal I will say new terminal and this is where I will create a Django application now for that you will say sudo docker compose you will use docker compose to create your django application because that's yeah so that's why we have a website web layer so here we will say it one the service name which is web so this is the web service you have to mention web and then the command the actual command the actual command which we are going to use is Django admin remember this is how you get a Django application and then you have to mention start project and then you have to mention the project name so I have my the main project name as the disco and the Django application which I want to create here is let's say what app I should create I will say my site I know that's that's weird well let's say my site and I will say dot this is in the current folder I want all this code I would say enter it will ask for the password let me just do that now it will take some time to create this because it will download all the required layers for you as you can see here so depend up depend upon internet speed depends on your machine speed it really takes some time so as you can see we have downloaded all the images here and we have the talker applications ready so if you can see on the left hand side we have a my site app and here we have settings taught you we have setting start by we have your got PI this is where the magic happens right but is it really working now first of all even before running the application ok it says we have to install the exchange and for python let's do that like extensions are actually very important so this is where the magic happens but then even before I think the application we have to understand the permissions here so if I do the least things you can see these are the projects we have so we have docker compose dot yeah Mille these are the files we have then we have the most important file which is managed or py and then our app here we have requirements dot txt but then if you see here we have the permissions issue here if you can see this two things have a dude permission now we don't want root permission B we want the user to have the access there and for that I would say sudo see it own - I'll I will use user user now using this I can change my permission so using this I can change my permission so if I said least so now I have all the permissions here now once I've got the permission I can do anything with my files I can delete my files I can create new files I can I did the existing files now once I got that it's time to run this project but how do we run this now of course I wanted this on this application on the container so this django application will be running inside the container which is running on the dock or engine and which is running on this OS so we have to go in a dock away and to do that we have to say docker of course we can build this image I can run it otherwise you can simply say docker compose and you can simply say up so if you want to start the container say up if you want to finish it you can say down let's say up it may take some time and it's up this okay it was quick I hope there is no error there is no error let me just try this so go back to my browser so that's my browser it's time to say 127 0 dot 0 dot 1 : 8000 I hope it will work and it's working you can see that we have our Django homepage up and running so yes we have not done any coding as of now and that's why it is giving you a default page but if you got this page that means your system or your your Django is actually running on the container example if I just stop this if I say ctrl C to stop the container and if I refuse this you can see we got an error so yes it was running because of the container now this is working but then if we don't want a simple application like this to be running on the container right we want to have something maybe I will just want to print a low boil if we can do that we can do lot of different stuff so how do we do that now if you want to create a project how will you do that so it's very simple first let's get this up and running and let's open a new terminal now of course you can use a terminal obvious quote all I can use external terminal let me just use external terminal here which we were using from a long time and here I want to use that docker image so first of all let me just see how many persons we are running so you can see we have this process all reading here it's going in two lines but let me just explain that so this is the touch of container ID that's your image name which is the new scope web that's the command it is passing to run this application and the important thing is the name the name of your container is the disco web one now using this container I want to create a new project or the new app so in the existing project we are we want to get a new app that's how Django works so if you want to have a separate thing you want to do you have to get an app and let's let's good nap here now how do we get an app it's very simple so you have to use the existing image existing container now if you want to execute something on the existing container you will say docker exe C which is execute and you have to mention the name of the image a name of the container that is the disco - web - one and then you have to pass the command the command to create a new app is Python manage dot py start app and the app name of course I want to create a app as grid so this will greet a user let's enter is it yeah so if you can see if you go to vs code we have our app ready so it's so simple might just use the existing container and create the app now once you have your app ready it's time to make it run so what exactly I want to create is if I go back to this home page and if I say slash hello it should print hello world that's it as of now it is giving you error which is for not for of course we don't have any pages or the app built for that URL now to make it work we need to go to our vs code and that's where you have to do the coding as of now let me just close all this files just to reduce the complexity of the application now how do we do that so whenever I add one whenever I say hello oh boy now for that if you want to do something on this trend you need to use you need to use views dot py that's that's where you define what response you want to send to the user so first of all if you want to send a response you need to import Django dot HTTP and you have to import what I study response now as I mentioned before if you're not familiar with Django I would I would recommend you to explore the Django series on this platform oh I don't have enough permission retry a super user I need a permission here so maybe I just need to do that once again do I have the permission for great yes I have a permission now but it's a bit work so of course you have once you create a happy up to mention that you need a permission there now once you've got a permission I will go back here and I was able to save this application now I want to create a function which will accept my request so I was a def and the function name can be let say hello I want to get a function for hello requests so is the request and this is where I will simply return the response I mean I'm just writing a way simple code they can make it complex by adding some new features and I just want to return hello boy but will this work of course not right it's not that simple so even if you code it any few even if you run this application by saying up it it will not work so if I go back to the browser if i refresh if I start afresh nothing is working so what went wrong see when you send a request it will use the we need to have a URL dot py file inside this great there is no way of specifying when to call this function the way you do that is by creating a new file which is you a little start B Y this is where you mentioned your the path so to do that you have to say from Django dot G URLs you need to import path again I'm not explaining all this thing in detail in this code there is a separate video on this you will find that in description area and from I want to import from all I want to import wheels now once you've got this - you need to specify the URL pattern so you have to say URL patterns and that's what you have to mention multiple parts in your application you might be having or in your app you will be having multiple URLs so we are doing it for hello maybe you want to do it for the payment you're doing for the some other request so you have to mention all this thing in this part in this you will patents have to say path I'm requesting for hello and I will say we use start home so views toward hello that's the name is it the yeah so fortunately miss hello so if you save use dot hello that's the function we are mentioning and then you have to also mention the name of the application name of the app so we'll say name of the pattern but okay so this is done from this side but will it work now even if you save and if you go back to the browser and if you say refresh oh it's not working why it's not working it still says hello 4.4 the thing is the main application for your project is my site and in this if you can observe we have you add s dot P by this is the main thing so you have to configure this one as well how do we configure this so I have to say path and this is where you have to mention whenever you get a request with hello you need to send request for okay how do we do that so you have to say include and this you have to mention the app name what's wrong yeah so in this you have to mention the URLs of green and the way you can do that is by saying great dot URLs so when you will get a request for hello this is where it has to map oh that means we don't need to mention hello here okay let's try I hope this will work I just I can just hope now let me just say up again oh we got an error it says what include is not defined oh my bad include has to be inputted here how can I miss that so I will say up again and it worked this you can see there is no error I hope this will work on the doors as well let's refresh the browser oh it working so that we got hello boy it's that simple that's what we can create a django application on on taco so basically you are talking with this on the container so you can just pack this image deploy it on the or push that on the docker hub and anyone can use it without any installation of course they have to install dock others this will not work so just to give you a quick recap what we have done first of all in your machine you need to occur and you also need vs code or any data type for that matter now once you have darker you need to create a Django application the way you can do that if you can just follow this steps here that's a new steps I guess we have done on the terminal now there's a first step is you have to create this folder which is the list cause you can create any folder and in that you need to create three files which are very important one is the daka file which where you have mentioned what is your base image and what requirements you have and you have mentioned all the requirements in this special file which is the commands dot txt this is where you have the Kwan's dot txt where you have mentioned we are using Django and in this Jiang and then we have gone for the cocoa compose where you have mentioned what to do when you start your when you start you start your container you need to run this server and when you don't the server Django was working but then we wanted to have our own own app there and the app which we have created is great we have written some command like this we have the over the command to execute that you will find this command in the description and for using the ID I've created this app and in this app we have to configure the views dot py we have to configure you LS dot py so that you can give the path and this in the main path in the main yours or py as well you have to mention the and that's it if you want to add new features create new app create new you are I mean great right some URL path trade some functions and this will work so I hope you enjoyed in the next video we'll see how do you continue lies the existing application as I mentioned there are two ways you can start the application you can start building the application on docker which we have done now or you can build the application and then can't rise it so that's it from this video I hope you enjoy let me in the comment section and do subscribe for further videos bye welcome back aliens my name is 720 and in this video we'll try to dodge the django application sin the earlier video we have talked about how can you create a django application on docker but then this time we'll build the application and then we'll talk arise it now of course for this for that step you have to first create a django application and then you can docker eyes it right so I'm assuming that you know what is django you know what is taco so in this video we'll try to merge them right okay so first step is in fact I was writing a django application a small simple application but quickly I will not be explaining these steps to you and for that first thing we have to verify is do we have the Django installation so how do we verify it so you can go to terminal and you can type django Django admin and you can say version and you can see we have Django install which is 2.2 so make sure that you have Django installed on your machine so that you can continue now once you have the Django installed it's time to create a project so we get a folder which is projects let me just check so as you can see I already have a folder projects I will just use that so I will just say projects so you can if you don't have this folder available just create one and you can get started now once I caught a folder once I'm inside that folder it's time to create a project so I'm creating a Django project so for that I have to say Django admin that's how you do it and then you have to mention the command which is start project and then you have to mention the project name so the project name which I'm going and I'm going for is let's say my site now once you say it will create a project for you but do we have this project available so if I say LS - L you can see record a project which is on my site so we have to so that's done record our project now how do we verify this so whatever we do is I will just jump to that project I will just go inside it and you can see we are inside that project and if you can you can verify the content as well so the most important file in any Django project is managed dot py so using this py you is using this file you can run this server so as you can see we have not written any code but the magic of Django is it will give you a ready-made project okay so you can simply use it how do you run this project now first of all I just need to check one more thing which python version I have so you can see when I say python version it is giving me 2.7 but actually I need Python 3 so for that I was afraid command which is Python 3 so basically I have to installation in this machine Python with Piper 2.7 and then we have Python 3 separately so I want to use this Python 3 to run the server so do check this on your machine do you have a default one as 3.6 or you have to mention python 3 here now based on that you have to execute the command to this server since in my machine I have to specifically mention that I'm using Python 3 and I have to say in managed dot py and I can says run server so remember this if your Python versions gives you three point any version then directly used by the neo don't say Python 3 but in case you have to mention by 3 to get the version then you have to mention it here let's run this server and see if this is how this is working so if I say enter ok so you can see we have not got any error and it says this server is running on this address let's click on this otherwise every time I will just type it so that's the address and if I say enter you can see we got a Django application up and running so as you can see we have not read any code but strategy's working right so this is a simple Django application demo application but then to get the real power we need to do some modification right what I want is in this application if I say hello it should print hello boil I know we are doing we have done that in the last video as well but just to keep it simple I'm going in that way I want to print hello world when you say hello and then we'll talk arise this application now to do this to make a change of course we need to use some editor and I will be using vs code so let me open that so as you can see we are inside vs code and it's time to open the folder so that's my site click on open and we got our project open here so you just have to open that folder which is my site inside this you only have one file which is managed rpy let's not focus on that what's important is if I if you go to my site we have this file which is yours dot P Y which is this which is which will be helpful to navigate in your project for different requests now to make it work of course I want to get a separate app and that's how Django works right way to get one word app and for that I need to start our terminal so in this terminal what I will do is I will create a new project so not a not a project but an app and you do that I will say Python 3 manage dot P Y P Y and then I have to mention start app so when you want to put a new project you say start project when you want to get a new app you say start app and then you mention the name of the app in this case I will say telescope so my project name is my site and the app name is the disco I'll say enter and you can see we got our app ready so we caught the disco app running here or available there now we have to make some changes maybe we want to make it make we want to run it for the hello world right and for that of course I am NOT going to explain each other everything so what I will do what we need to do here is if so if you want to get the more information about this thing what I'm doing you can watch this Django series which is available in the description area and ok so we need to get a function for the request acceptance I will say hello I want takes at the question hello so I will say request need to pass a object and then I don't want to print anything I would simply say turn HTTP response and avoid okay so once we got this code here we got hello world so this should work I do need semicolon there okay so this should work but then we need to do something more because if if you want to call this function you have to also inform your URL in this app and we don't have you waddle so for that with a paid new file which is URLs dot dy which will help for the navigation and here I will say from Jango dot URLs import part from dot import views ok now once you've got these two imports we need to specify the parts all the parts in your app then in this code we only have one so let me set that so have to mention the part and which part will keep it blank here I will save use dot hello so in the view you have to call this function which is hello that's we have here I want to call this function and we can also have a name for it let's specify name as hell itself that's it we have to specify that stuff here and the most important thing is you have to go back to your main app where you also have yours dot py this is where you have to mention for all the hello requests you need to call the the telescope and the way you can do that is by saying a path and here you will say include then you store the word URL so you have to navigate to this particular URL of the risco but it says we need to import include let's do the right ok job is done and that's it just need to verify one more thing security key is available allowed who's just not mentioned but that's fine let's go back here let's see if this works so let me just run this application once again I will go back to my terminal just here and say on the server again there's no error let's go back to the browser set afresh and we got an error it says you are lookin fine okay so I just need to mention so I guess I messed up with the part let's on the server once again and go back to the browser oh it should be hello my bad let's not this ever once again go back okay that was the mistake so the mistake was you have to mention hello here because we are navigating whenever you get a request for hello you have to navigate to the daily spot URLs and then I kept it blank mistakes anyway it is running right this is up and running but then I want to run this on a dock container so you have to shift this to a doggo container now how do we do that it's actually very simple what you have to do is you have to create certain files which will inform your docker that this is the app you wanted opera eyes and you're also in to check do we have dhaka install so i will set our version and we got a dhaka version so yes docker is also installed in this in this machine if you don't have it follow my tutorials on taco and you will go doc you will get darker here so don't do is i in this project in the main project you need to create certain files the most important file which you have to create is is this one so i will right click here and I will say new file and the file name should be docker file nothing no extension you have to make sure that your D is capital and F is small if I Center now this is where you have to write some commands to do it see when you talk about docker when you when you talk about the application you want to run this in a container right so basically you have to create a image out of it now do we get the image so basically you have to create a layers so you have to mention the base image and then you can add some news new things on that so here I want to specify the base image so I want to start from the base image I want to start from is Python so I will say python version 3 that's our base image the next thing you do is you have to mention the working directory so I will say working directory I want it to be apt then you have to add all these things into the app so I will say add all the things to app now once you have done that you have to set some environment variables as well let me just do that on top here so the environment variables which is one of the normal have to set is unbuffered which is one okay so basically you have to create a working directory which is app and then you have to move all your files to this app and you have to also install certain things see when you get the image you will get white and white but then you want Django as well so how do you mention that you want install Django on on Python see we need one more thing Django will give you a server for short light so every Django application comes with internal server but then when you move your app to the production server you need to have some specialized servers you can't simply use the demo one provided by Django and that's why we can use a unicorn which is I don't know how to pronounce it is a unicorn or J unicorn you need type in as well so you can mention those things in the in a separate file so what I will do is I will go back here and let me create a file called requirements dot txt this is where I will mention all my requirements in fact I have only two requirements here Django and Gigi unicorn so it's a Django I want Django version 2.2 and what else what else I want I want Gina corn or J unicorn version let's say twenty twenty point zero point four this was working so I've used this before and this was working you can check these latest version you can try it out I think it should work now once you've got these two dependencies in the requirements dot txt we need to use those requirements in this docker file you have to instruct your docker to install those two requirements and the way you can do that is first of all you have to copy those requirements in your container or in your image you have to say copy dot DX to the parent folder and the current to the app with name requirements dot txt okay so your puppy requirements or txt to the requirements dot txt that is done and then you have to run the installation so you can use p IP install our and you have to mention the filer which is requirements dot txt and that's it it will install all the required dependency required librarian you have in your in your system and once you do that you need to I guess I can add at the end as well or let me just say a copy once again just to be on safe side let's do step by step okay so um I got the base image I got your working directory I'm adding all the content to the working or to the app working directory and then you have to install the packages and move that to the app now once you got this docker file ready it's time to run this hey hold on see whenever you have multiple containers if we will be having a server will be having the application it's better to work with Django docker compose so in this to learn this good to learn this application I will be using docker compose so go back here and I will say docker compose dot yml just one change this should be talker so you can see in when your vs quad says this is a docker files so you can see record a different logo here okay so what you have to mention the first thing I have to mention is the version of docker that's done version three and then you need to open up the docker compose configuration now whenever you want to create a django application which is a web service right which is a web application so you have to mention these services which are going to use maybe you might want a database service your want a web service in this example they are only going for web so I will use a web service and then here I will say build the current folder and then to run this application I have to pass a command now what command you need to run this and we have done that before right so to say Python 3 I guess we are the insert of container so container will directly go for Python command let's do that man's dot py and run server remember this when you were running running this on the local server or the local machine from a machine deep there was an issue with the Python version I have to specifically mention three here but when you work with containers they will be treating Python as Python 3 you don't have to mention that and that's the beauty of using containers and then have to also mention the the allowed addresses see what happens is when you run the application on docker container it will be having a different network system or network resources and you will be sending a request from your browser to the to the server or to the container and for that you will say accept requests from everywhere so you will say 0.0.0.0 and you have to mention the port number as well and the allowed port numbers let's do the port bindings here and port binding is for 8,000 and that's done okay that's how the quantification we have to go to docker file we have to compose file and they should work now I don't think we have with some extra step let's verify ok everything looks good let me go back here and let's run this application so first of all is set clear now how do you learn this see since we are using docker compose for the for these for the settings let's use docker compose itself so I was a docker compose you can use up or you can also say build it will build the application now and it may take some time to build it so a second city is installing all the requirements you have mentioned the Django 2.2 the J unicorn and once it is done it will build the image for you and after building the image it will give you the ID as well ok image is build and it is tagged with the help of my site web now let's run this I will say docker compose up it will run that that is my site web so you can sit says creating my site web 1 which is a container and we got an error it says this is already in used o because they already running a server terminal remember still get to shut it down before done in this one let's do it again okay this time you have you can see we don't have any error let's go back to our browser and say refresh and you can see it is up and running but this time we are doing this on a container not externally okay so you can see we are so near the question whether it is working perfectly so that's how you penalize your application so we are creating the application and then we are moving it to the docker or we have a dock rising it basically the only thing you need is additional files three additional files one is docker compose docker and requirements dot the extreme so I hope you enjoyed this video that man in the comment section and deuces go for further videos bye bye
Info
Channel: Telusko
Views: 86,686
Rating: undefined out of 5
Keywords: telusko, navin, reddy, tutorial, java, python, blockchain, django
Id: GGaDSAMeopo
Channel Id: undefined
Length: 90min 30sec (5430 seconds)
Published: Thu Jul 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.