Hey you Yes you you who is watching this video has it ever happened to you that you are developing an application or have developed a web application and it works wonderfully on your computer That application is wonderful on your computer however you pass that same project to your partner your partner tries to test it on his computer and gives him a sheet of errors you know why this happens this happens because you don't use docker And yes you have to learn docker And you know what is best that in this course I am going to
teach you dockers from zero you are going to Ender from the basics to advanced topics And how much does this course cost, well it costs cer soles $ in this video I am going to teach you absolutely everything you need to master this tool this powerful tool called docker Let's get to the point What is docker exactly Look what heck, docker is docker, the truth is that it has many definitions, you go to the internet, you write that it is docker and an infinite amount of information will appear, but here I bring you a fairly
simple proposal docker is an open source project That automates the deployment of applications within software containers, what does this mean, this means that docker is going to be in charge of deploying the entire application that you develop, that application in which its library has its dependencies necessary for it to work, it is going to be in charge of packaging it in something called a container. container is a container which is going to be transported to some part of the world that is what we know about a container and here in docker the concept of a
container would be very similar because a container in this case would be like a container but in that container you You are going to save an entire application with the libraries and independence necessary for this application to work. And now you will be able to use this application anywhere on any computer without any problem because it is inside a container and that container has everything in isolation. container works autonomously but well. What is the difference between working with normal applications and using docker? Look, let's suppose that you develop an application, you are using the Java
language, true, you are Using Java, you are using, I know JDK8, you are using a version of springboot, a version Specifically, you have your application and everything is cool, well, then you want to use that same application on another person's computer, you go to another person's computer, or rather, you pass that project to the person, the person tries to use your code, however, when the person downloads your code and tries to test your project in their application or rather when they have your project and run it, they get too many errors, right, they say, hey,
you know, you don't have this version, so you can't use it. Hey you know what, you have to download the library So you can't use it Hey you know what This is not compatible Because you need so much ram Hey you know what And it gives you too many compatibility errors, it is not the right environment, so to solve this and many more problems, it uses docker and as we can see on the screen docker is a project it is a tool that automates the deployment of applications within software containers well everything that Has to
do with the word automate is that it will have less human intervention everything that is automation So we are not going to be in charge of managing the resources and the rest is going to be taken care of by docker itself, although we can do it too Of course, but it is going to be in charge of it for a reason. It is a tool, so next Why use docker Why do we need use docker and well a moment ago I told you several reasons. Look, docker has several characteristics for which it should be used
and you need to use it and one of them is portability, the next would be isolation and then resource efficiency when I talk about portability I mean because the containers or rather docker is in charge of encapsulating an application or absolutely all the applications that you have in containers, each container works autonomously independently. Better said and for this reason it is considered to have a isolation, what you have in an application or rather in a container will not affect absolutely any of the other containers because you can manage 10, 20, 30 Containers or the number
of containers that you want to have, so it will not affect it. in nothing if you make the change or some change to a container The others will continue working independently resource efficiency Normally we used to work with virtual machines and we had our applications in each virtual machine we can communicate each virtual machine with the other and well this was the traditional way of working but with the virtual machines it was really heavy because remember that each virtual machine needs its separate operating system we have to give it a part of the Hardware and
it was like a little heavy so with docker the resource efficiency here is great Why Because first we are not going to spend so much memory so much disk right so much cpu well then the resource efficiency here is something that stands out because docker remembers that it does not have to have its own operating system that is, each container Better said, it does not have its own operating system, everything can work under a single operating system well So these would be Some of the reasons why you have to use docker also a moment ago
I showed you well I told you an example about an application and when you want to use it in several parts well so these would be some reasons why you need to use docker right now virtual machines a very important concept which we have to review before we go into practice and start executing many commands in docker and They are virtual machines. Well, what is a virtual machine? Virtual machines are completely independent computing environments. Well, just like docker, they are independent and virtualized, running within a hypervisor on a physical server. Well, here I am going
to clarify some concepts: a virtual machine. It is an environment which has its own operating system well and its own memory its own Hardware So to speak it has its own cpu its own RAM memory its own amount of disk well then each virtual machine has to have its own operating system Yes or yes A Unlike a container, you don't need an operating system and we need to review another Hypervisor concept. What is a hypervisor? Look, a hypervisor would be like a supervisor who is going to be in charge of creating virtual machines. That's it.
That's all good. That would be a hypervisor. We have the concept of docker Look if you don't understand very well what a container is Don't worry because we are going to see how we can create a container in practice with the commands well so don't worry if you don't understand very well what a container is already with the practice we are going to reinforce all this well so we have the concept of a container we know what docker is And why we use it now we see a virtual machine we know that a virtual machine
is an environment well it is a computing environment which has its own operating system and its own resources well Now we know what a hypervisor is, it is the one that is responsible for creating all these virtual machines Now I want to talk to you about a very well-known skill that you have to know and that is virtualization, it is a very important concept, basically virtualization is the skill of being able to create several environments, several virtual environments, that is basically Several virtual machines, now that you know what a virtual machine is and you know
what virtualization is, it is the ability to be able to create several virtual machines, several environments and each environment is going to be independent, it is going to be have its own operating system as we can see on the screen here we are applying the vir I ation and here we can see three virtual machines Here we see a hypervisor and here is the infrastructure well through virtualization using a hypervisor we will be able to create each virtual machine now We are going to assign each virtual machine an operating system, the amount of resources necessary
for it to work well. So this would be the concept of docker virtualization versus machines. virtual Look Normally we used to work with virtual machines, you had your applications in a virtual machine then you took it to a production server, well everything was cool but there were problems and the thing is that the virtual machine you have to be managing you have to be there you manage constantly and that was a bit heavy for us, so it used to be good, Now docker is usually used, virtual machines are not used much anymore unless, for example,
normally you also downloaded a virtual machine. And if you wanted, for example, to stop with a system operating like Linux Linux you had to install it in that virtual machine and you can to be able to execute its commands now You can simply download an image from dockerhub and use Linux well but those are concepts that we are going to see later let's see docker and docker virtual machines versus virtual machines here we can see the architecture of docker and a virtual machine in docker We have several containers here well here we can see several
containers and unlike virtual machines virtual machine needs an operating system And well, already realize this with this simple image As you can see, we are going to have to manage the amount of resources for each virtual machine, that would be very , very tedious. Unlike using docker, since we are not going to take care of that part first, we do not have to install an operating system, we do not have to give it resources no These are Independent and you know what is best, the best thing is that we are going to be able to
run all the containerized applications on any computer, no matter what it is, you are going to be able to run them well here we can see a little about the architecture of docker the architecture of a virtual machine well then What is a container the most important concept look a container is a lightweight and portable software unit that encapsulates an application along with all the dependencies and libraries well a container is that unit that encapsulates an application with all its dependencies and libraries now that you already know more or less what docker is well That
is a container now that you know at least What is this tool we are going to install this tool we are going to install docker on our computer and it does not matter what operating system you are using it is already using Linux Windows the installation is going to be very simple we are going to install docker to be able to install docker the first thing you are going to do is go to any browser and you are going to write docker is step one we are going to enter the official page and well here
we have a nb we are going Let's go, I'm going to go here in the part that says developers or developers, let's go to the documentation, we give it a cli and here we click on G docker And well, it takes us to the official page to be able to install docker, look here you have it for MAC for Windows for Linux I want to clarify something from the beginning of this course. Normally in productive environments, work environments, Linux is usually used as the operating system, but if you don't know Linux, don't worry. In this
same channel, we have a course called Linus from scratch. I'm going to leave it here for you. the cards so you can see it is a 5 hour course it is a very practical course in which I teach you everything you need about Linux well but in this case in this course I am going to use Windows probably many people do not know how to use Linux for me better Windows well then Windows Let's click here on download stock docker for Windows ready Now there is something very important you have to have certain requirements in
your system first we must install wcl this would be like a Windows folding that is, it would be like a Linux subsystem for Windows In other words, you have to have this tool downloaded Well, dcl sl tells us, for example, here We have to have a 64-bit processor 4 Gb of Ram 4 Gb of ram at least what else and here we are going to continue reading something very important, you have to enable the virtualization in the bios if you don't know how to update the How you can change the virtualization or how you can
enable virtualization in the bios I recommend that you watch a small video that you read a manual right because it would be a bit heavy to include that part here but the truth is it is quite simple and we are also going to enable a few things to be able to work with this efficiently. So we already have the docker tool downloaded here that we are going to install but hey we are not going to run it yet since we are going to Let's enable some things that are a little important well then the first
thing we're going to do is for example let's go here to what it says eh control control control let's write control to go to our applications here I'm going to go to programs and I want that you go to the part that says says we are going to go here to uninstall a program we are going to go to the part of activating or Deactivating Windows features the part here we are going to simply click to activate or deactivate Windows features ready here you will have like a small window look here for example you have
several options but I'm going to I want you to enable the part that says subsystem of Windows for Linux for Linux that this would be the wsl true the tool that we have to Download but to To be able to use it we have to enable it here in Windows and another very important thing that I want you to enable is the part that says virtual Machine platform well we can work with Linux and we can also work with a virtual machine Because at the end of the day the containers are like virtual machines but
They are not virtual machines since a virtual machine has an operating system, a container does not. Well done, I want you to enable these two options and you are going to accept. Most likely, it will ask you how to restart. We are going to wait a few minutes while it is updated. As I told you a moment ago, Windows asks you to restart your computer. I recommend that you pause the video From the course and restart your computer, I am going to do the same, I am going to pause the recording and I am going
to restart my computer now that you have restarted. your computer, if you notice, the docker desktop icon appears that we have enabled certain things, ready, what we are going to do now is install, we simply right click on it, right click and open, but be careful, before continuing, do not continue reading the documentation, be careful, we already have These options are enabled Now I want you to enable virtualization in your bios, how do you realize? Well, it's very simple. You're going to write task manager here. You're going to click on the part that says manage
tasks. I want you to go to the part that says performance services. We are going to give performance, look at performance, you are going to go down. Well, you are going to go down and here you are going to see a part that says virtualization. In this case, I have it enabled. I want you to realize it and I want you to enable this virtualization on your own. Well, they are simply configurations. OK, but it is something that I ask you to do, please. To avoid problems in the course, I am going to close this
part here perfectly. Let's continue, it asks us for One more thing that we have to install, wsl is the Linux subsystem for Windows Windows. sub System for Linux Let's click here to install this tool it tells us that we have to install it here okay okay ta ta ta ta good Windows Start navigate to settings Okay it tells us here How we have to install it but I'm going to show you a way It is quite easy to install it from the Powers shell. We are going to give it Power shell here and we are
going to give it run as managed and here we are going to execute some commands. We can also review this here from the official documentation. Be careful, we are not going here, for example, to the documentation of docker and tells us the following Hey, you have to install wsn, it is the Linux ls subsystem for Windows ready and preferably it tells us to install version number two well. So we are going to do something very interesting, we are going to go here the powershell, let's go powershell and We are going to write the following Command
wsl less less install to install the Windows subsystem Windows subsystem for Linux and we are going to give an enter We are going to give it in this case it tells me that it is already installed in my Case but you are going to install it well you are going to give it this Command it tells me here to enter a name Well I'm going to enter my name Cristian new passw 1 2 3 4 1 2 3 4 ready ready Simply I am reinstalling it and we are going to wait a few minutes and
in my case it tells me that everything has been completed successfully. If you have any errors, please let me know here in the comments box so I can help you and not just me, the community will help you. To be able to help we give an exit to get out of here we do a let me do a to clean the console ready we have this version now what I want to do is change this version to version two we have the Linux Windows subsystem installed but I want to change this to version 2s Then
you are going to put wsl menu set default minus version and you put two that is very important that you do this and I recommend that once this operation is done you restart your computer again well but ready we have these two options activated ready Now we can install Locker satisfactorily, come on, click here and we'll click on open or run as administrator. Well, Here it tells me if I want to add a small icon to the desktop, in this case, when docker is installed, I'm going to say yes and I'm going to click on
Okay, well, absolutely everything necessary is being installed here. Look, it is important that you have made all the configurations that I mentioned a moment ago. For example, you enable avos so that it allows virtualization, you install the wcl tool, you change the version and everything that I just showed you is important because if not you are going to have errors. When installing this perfect tool it tells us that the installation has been completed and it is very important that you do everything that I mentioned a moment ago again We are going to click on Close
and here we can see well in this case if we write docker desktop we click on open we need to open this application when you work with Windows you have to install docker stop Yes or yes so that you can work correctly okay We click on accept ready, on the other hand, unlike when you work with Linux, it is the native docker system. Well, here you would no longer have to install docker deop no, this is installed for Windows, here It tells us for those who I am simply going to hit jump, jump and that's
it, that's it, here you have docker de stop well in my case I am already registered But we are going to see this later we are going to see here the images volumes eh the containers and well Let's open the command prompt well Let's open the command prompt eh Let's click here eh cmd ready clear cls Better said look what we are going to do next is run our first container What do you think good again recapitulating what a container was You know that a container was like the instance of one of an image well
or it would be like a unit eh that has a project has a web application And that web application has all the necessary dependencies and libraries So that container packages all that and well for that we are going to see some things here Look, I want you to understand something, containers are born from images, this is for you. I will explain later in more detail but I want you to know that before a container there is something called an image, the image is a template that contains the entire application but unlike a container, The container
is already running and is ready to go. production, an image, not an image, is read only, it has everything necessary so that it can be converted into a container, the container is that same image but in execution and well, where are these images? There are many images in the world and they are going to be stored in something It's called docker Hub, which is an image repository. Well, what I want you to do is the following. We're going to write here. Docker Hub. Well, I want you to do doer. I'm teaching something that is not
yet ideal to teach you. And we're going to write Hello World. Hello World. look here we have an example of Hello World So let's run this image Let's click here docker Ram Hello World and we give it an enter Well ready in my case if we click on it after placing docker Hello World and we make a docker PS docker PS - Look, there is something very important. When you place the docker command, you tell it using docker Ram to run an image and remember that containers are born from images and well Simply if you
give it docker PS it is to be able to list the containers But there is a Feature that I am going to explain to you in a moment why it does not show us the container So we have to pass the minus flag to so that they are shown all the containers Even if they are turned off in this case it is turned off but here we see Hello World and that's it you just ran your first very interesting container right well but this is only a small introduction we are seeing more or less a
small introduction we already have all this installed docker is what is necessary Now let's move on to the good stuff and start with the commands we already have docker installed we have already run our first containers impressive right well Now I want to talk to you about another very important and fundamental concept in docker images What is an image an image is a read-only template that contains all the elements necessary to create a container. We know that a container is that, well, it is that unit that has an application with all the dependencies and libraries
ready to take it to a production environment. Well, that is something very important that differentiates it. of an image an image would be like a template Before you create a container you need an image well then Imagine that the image is like the template that has everything necessary so that you can create that container and you so that you can generate a container From an image you can do it in several ways with a command or with a specific file called docker file that we will see later. So I want you to keep in mind
that the image is the read-only template that contains all the elements necessary to create a container So if the image is the template the container is going to be an instance it is going to be that same image that template but in execution ready to be able to take it to a productive environment So now you are very clear that the image is the template and the container is the instance is the execution you can have many many images and each image can have many instances that I want you to keep in mind you have
an image and from that image you can create many containers you can have many instances well that is Something I want you to keep in mind is the concept of an image But now we are going to go to the console or rather we are going to go to our terminal and we are going to execute all the necessary commands to be able to create and manage all these images in docker now Now that you are a little clearer about the concept of what a container is and what an image is, well, we are going
to see some examples and for this we are going to use the commands, I want you to understand something about all the images that we are going to use in this course and What are you going to use? We are going to get them from an image repository. We are going to talk about this later, but now that you know what a container is, an image is going to be able to get these images from something called docker Hub. Dockerhub is a repository. of images in which all the official images are found, whether from Linux,
Java, python, enginex, My sequal, mongodb, any technology , for this we are going to use several images of those mentioned technologies. Look, we are going to do the following, we are going to do something like something like This docker images we are going to execute The docker images Command docker images The docker Im Command is going to allow you to list absolutely all The images that you have on your computer we saw A very simple example like docker Ram Hello World Hello what we do It is basically with docker We are indicating that we are
going to use docker and that we are going to run an image This is to run a container but I want you to keep something in mind this one here is to run And this is the image the name of the image this is going to become a container you understand me If you put docker PS it will show you the active containers but I explained to you a moment ago that docker has certain characteristics and this container runs but at the same time it is paused and to see the containers that are paused it
is docker PS - in a moment we will see how we can execute containers and that these are not paused and that they appear active here to see the containers, absolutely all of them are active or you do not have to place docker PS - oh well, if we go here to docker desktop we can see in containers, for example, this one here we can eliminate or we can run it. Also here in images we will be able to see the image that we have downloaded Ready this is a little of what we saw Now
I want you to also keep something in mind we are going to write here dockerhub later we are going to see how we can Log in register in this repository but basically This is a repository that as you can see has many images Look has images of redis of kubernet of openjdk of go of php of [ __ ] of not has many images and you can work with all these images download them and run them to Let's see a very interesting command. If we look for a docker image, we place docker docker Search and
look for the image called enginex. Ready, we give a docker Search enginex and look, it will list absolutely all the images that it will find. in docker hub for example here it shows me the official one from enginex Look let's go here and for example I'm going to look for the one that says redis the redis image okay So we make a and place docker Well a cls Excuse me docker Search ris the redis image and here we can see redis here you have a small description and it tells us that this is the official
version well So the docker Search command is used to search for an image we are seeing docker Ram docker PS and docker images to be able to see the images that we have downloaded in our computer and we only have one which is hello world we are going to clean when you run a container and that image does not exist on your computer it will be downloaded automatically that you also have to take into account well and for this we are going to see something very interesting we a moment ago we made a docker search
engine docker docker p you put the name of the image in this case ng next and you can eye you can use any image the image of the Open jdk openjdk the image of python the image of [ __ ] the image of php but for this case we are going to use enginex we give it an enter ready Look at an image I want you to keep in mind that it has something called a tag and this tag is Let's say as the name The version of the image tells us that it is latest
well that it is the last one is downloading the image Now there is something very important we place docker docker images Look we are going to make a cls and we are going to place docker images if you look here you can see that there are two images previously we could only see one but now I see two and it is the Hello World one and the enginex one what we just did with the docker pool command and the name of the image is Download that image from the image repository True, it is the place
where all the images are hosted ready, we just downloaded an image on our computer What do you think if we run that image but we are going to do that in a moment we are going to see now How we can Delete this image if we put docker images on it it is to list the images But what do you think if you want to delete a particular image to be able to delete an image for example the image Hello World we have to put docker rmi and we put the ID of the image or
the name, we are going to put the ID first the ID for example this one here Well it won't let me copy it so let's put the name Hello Hello World And that's it In this case it tells me docker PS well it tells me the following error it tells me that there is a container for which you cannot Delete this image So you cannot delete an image if this image let's say belongs to a container you first have to delete a container but at the moment I have not shown you how you can delete
a container, be careful, I am going to show you next docker PS - a because remember that this container is turned off yes You see here its properties we see the container ID the image here is something super important you see the image to which this container belongs obviously. In other words, to which image this container belongs you see The Hello Command And you see how long ago it was created in this case 22 hours ago well in this video a few minutes ago but I have cut out this part here it tells us for
example that the port has exited it doesn't tell me and here is the name so I am going to delete this container I am going to delete this container What do you think docker docker rmi to delete a container it is not rmi it is RM and then the container ID comes the container ID or the ID name comes but since This one does not have a container name I am going to copy the ID let's copy this one let's see give me a minute let's go let's copy this one here let's copy well in
this case I can't copy it but I'm going to write it manually 642 642 f00 a00 68b this way we're going to delete the container and that's it docker PS - a docker PS - okay the container is no longer there There are not even those that are disabled docker PS and we are no longer going to see the container. What we have just done is see another very interesting command, which is the docker RM command and you pass it the container ID. What we have just done is delete a container. now if we do
a cls for example a docker PS docker PS there is nothing more docker images we are going to delete for example rmi Hello World now it tells me the following that docker images image has just been deleted and Hello World is no longer there what we just did is to delete a container we have just deleted a container we are going to delete an image we have seen How we can list images and How we can download an image from the image repository now that you know more or less How a container works an image
where an image comes from And how run a container run an image of a container let's focus a little on the management of commands for containers well. So what we're going to do is work on the Linux subsystem for Windows we're going to place wsl the console and what we're going to do next first let's run well I want to see if we have any containers here we don't have anything So let's run one Hello docker Ram Hello World Okay ready docker docker PS okay docker PS men a to show all and okay here we
have this one here that just shut down okay but in a moment we are going to see how we can change so that this container is active for a few moments well Look, I have here, for example, this container I have this container, I am going to delete it docker PS - I am going to delete it docker RM and In this case it is id 17 or better to save time docker desktop delete this would not be a good practice if you are learning but for the example we are going to delete it, look
what we are going to do is the following we are going to run a Rocket Ram container again with the Hello World image but we are going to give it something, it is the name, a name to this container to be able to give or assign a name to the container we have to put less less name and I am going to put container a in order to make our work easier and We no longer have to write the ID but simply the name of the container in this case it would be container un and
we give it an enter well we put a docker PS men a we are going to do a docker cleaning PS men ay we see here the name of the container container a Ok, what we just did is assign a name to a container. This is also something very important. What we are going to do next is inspect this container. We are going to see all the information about this container. To do this, use the docker inspect command and name it. of the container container 1 well these properties maybe at the moment you do not
take much importance but in the course of everything that we are going to see we are going to see for example something very important such as the name of the container Here is name container one what else Here we are going to see the volumes and the networks to which they belong, it will also be a Very interesting topic that we will see more and what else we can see for example the name of the Host well what else to download and well ready ready here some properties of the networks networks is bridge Default here
are several properties, it is basically Data information. For example, here is also the date on which that container was created, 2024, and here we see the ID and the rest is ready. These are some properties of a container. And as I said, I want you to take this Command into account. because later we will see it when we see the topic of volumes and networks ready interesting what we are seeing now we have two containers here Well one container Even though it is off But we have a container ready But what do you think if
I want to run again another docker container Ram Hello World okay And I give it an enter docker PS men a Here we see two containers Look at something that I want you to keep in mind if you put docker PS menu here you just ran a container but you didn't pass it the minus name property Here We see a name happy happy Win, this name will be assigned by default if you give it a container or any Other name if you do not give the container a name. For example, if I want to run
another docker container Ram Hello World and We are going to pass here less less name container a container one if you give it that it is perfect that an error will appear because you are trying to run a container with the same name you cannot have containers with the same name the names of the containers They are unique, a very important property if we put docker Ram less less name container 2s Hello World now it will allow you the docker container PS men a to see all the containers and here we see container one two
well ready we are seeing a little bit of the management of the containers and some of their properties well since you know how to also delete a container you can delete a docker RM for example I want to delete the happy happy one and I save what the id Happy Win is ready docker PS men oh that perfect container is no longer there something very important How can you eliminate absolutely all the containers because imagine that you have 100 containers you are not going to want to be eliminating one by one well There is a
very important command that is very interesting is the docker command docker container room an enter and it tells me ee attention This is going to be what it is Delete all the containers Well I simply want you to delete them and that's it delete the ones from my life docker PS - that's it it's a very interesting command as you can see we are looking at how to list the containers How can we inspect the properties How can we run a container How can we give it a name How can we delete container by container
How can we Delete all containers Now there is something also very important docker PS for example men a Well I also explained it to you that it will allow you to see the containers that even they are not active ready good everything is perfect now we are going to work with another container with another image that is docker RAM unun well but now we are going to put this property less it What does less it mean this means this means that it will work iteratively To put it this way, what it is going to indicate
is that this is going to be executed in an interactive mode, which means the user is going to be able to interact Directly with this container and for this we are going to see the following example, we give it an enter and well, as in In this case, Ubuntu is an image. My computer does not exist. What it is doing is downloading it by default and we have to wait while it downloads this image. Now there is something very important that we see here on the screen. We have run docker Ram, except for it. Ubuntu,
this means interactively. What is going to happen is that you are going to be able to interact with this container and look, I get the following: I get a terminal, a series of this is the terminal with which we are going to be able to interact with this container, we are going to do a clear, for example to clean the console and here let me tell you that we can execute many things for example a docker in this case there is no docker but for example if we put an ls and we will be able
to see for example an ls etc pas wd wd I think it was from this ww ready for example a cad etc pass wd to see some things in the files well and well Here we will be able to execute any Linux Command but it is not to see Linux but more or less show you How the interactive mode works well That is a bit of the Interactive mode when you pass it less you will be able to interact with the container if we place it we place a docker images Here we see three images,
the one from enginex ubunto and a call Hello World good Now what does it look like if we want to create another docker container Ram less we are going to put less less name good it will be called Always Look I am going to make a docker PS docker PS good and in that case no active container all are active inactive yes I I put docker PS - now it does launch me, for example, this container here but it is inactive And that is the problem that we have had since the beginning, any image that
we are running is active How can we make it so that it is active, let's see an example conun we are going to make this container active docker Ram minus minus name and we are going to call it This way Always So it is always active - d well we are going to put os d so that it runs let's say in the background we are going to put ubuntu in it name of the image and we are going to place a very important command, this Command that I am going to show you is going
to allow you to Activate this container Tail - F bar dep bar null this I am going to make it a little bigger more or less Look to you can see it here too Look docker Ram less name I already gave it the name and down here you have to put the name of the image name and this Tail Command - F dep n This is the command that I am executing well So now I I'm going to hit enter so you can see it and if I put a docker on it PS Look at
the magic that is happening with an active container for the first time of all the containers we have been practicing. This is the first one that is still active. Well ready, here we are assigning it the name up well and then we are going to pass it - d which indicates that it will be in the background and what I mean by background is that this is going to keep this container running ready well and for this we have to use the command Tail - F bar dep bar null ready this type of container will
always be active it will always be useful for certain cases well. For example when you need an active container but it does not need any specific functionality but you need that container to be active well Then like this This is how we can run a container Now I will give you a practice so that you can run that same container again with that same property but with a different name, for example Always up two docker PS and here we see two active containers Good ready, we are working with containers ready very interesting what we are
seeing at the moment but now we are going to see something much more interesting we are going to write the following Command docker Ram docker Ram less it in interactive mode to be able to interact with this contor less d we are going to put it in detou mode in background and another very important property that we have not seen at the moment is the property is not just executed but we are not going to re-execute this minus p minus p it is going to tell you the ports I want you to know something very
important first you are going to put the port of your J be the port of your machine and then Lu the port of the container what I mean is that you are going to put 80 80 and it is the port of the machine and then the port of the container to which I What I mean is that the machine will be able to communicate with the container, that is, your 8080 machine will communicate with the container, which is port 80, and your container will also be able to communicate with your Host through 8080 because
this is the port of the Host difference that this is 80 for the container So this one here is going to be assigned to the machine and this one here is going to be assigned to the container well one is the port of the container another is the port of the machine that is very important and we are going to put less less name it is going to be called web it is the name of the container and we pass it the image ng next ng ng next but I am going to indicate ng latest
what we are doing is I am going to run a container in interactive mode to be able to interact with it well now except what this indicates is that it will allow you interactivity with the container ready in a command line for example less d what it's going to do is run this container but in the background what it's going to mean is that you for example uh this container is going to run fine and let's say it's not going to be paused or rather it will release as a terminal so that you can continue
using the command line without blocking or - d Ready now okay And then minus name which Indicates the name of this container which is in this case web and we are going to add another thing at the beginning of all this Or rather after this it for example we are going to put less less RM this what it means is that this container will be eliminated automatically when it stops That is, as soon as you stop this Sas container it is eliminated we give it an enter and we place docker PS well if you put
docker PS you can see here another container that is the enginex container and that's it we have just executed a container seeing a series of docker commands the flag goes less it men men RM men d men py less less n what I am going to propose to you is that you practice practice with this entire Command. In other words, you make several docker RAM for different images. I know how to do images. Do this same Command for 10 images and change the ports so that you can practice all this and one way or another
don't forget. Well look here we have, for example, three active containers. Do you think if you try to pause one, for this you are going to put docker stop and the name of the container or the ID of the container? I don't know, for example. the name Always is here docker Stop app Let's give it a few minutes to see docker PS docker PS let's see we continue here Always docker stop Always up ready now if you put docker stop in it the name of the container And if you put a docker PS in it
it is no longer there the container now we can only see two docker containers PS - okay Now we do see all the containers ready so what we are seeing is How can we interact manage est with these containers How can we execute them How can we use them How can we create them delete them ready well let's continue for example Another very important Command which we can execute with elando is this menu menu 3 menu F minus F we are going to place Dep bar null bar in this way in the same way docker
PS Look at the difference when you put less less it you could interact with this the command line but now when you only put less d if you put a docker PS it goes Here show ubun ubuntu in this case it is like ubuntu ubun 3 good Now going back to what we were a moment ago which is this Command here This one here, not the other one here flying This Command, for example, now we are going to execute the same thing but with a different name web2 well docker PS Ah well and we are
going to change the ports we are going to tell it to say 70 70 70 and we are going to indicate web 3 Good ready docker PS and here we can see for example two web 3 which is the container that we are running well Look you have this Command doer men it men d less Port I want to reinforce the issue of ports well the first Port which is 70 70 This is the port that is going to map to the Host That is, to your machine and then it is the port that is
going to map, so to speak, to the container, which would be the port with which the image communicates enginex So to speak Now there is something very important that I want you to know. Keep in mind, this does not mean that you have enginex installed on your machine, but what it means is that your machine is communicating with that container through that port, that is, thanks to port 70 you will be able to communicate from your machine to the container. and you will be able to obtain the data well. That is something very important that
I want you to take into account. This establishes a small connection on both port 70 and port 70 of the container so That requests that arrive at port 7070 will be well received. They are going to redirect to this one here Port of the container where that image is executed well we are simply and doing these parts we are going to here to put a perfect this would be a little How can we manage with and work with everything that are the containers in docker in fact that everything we are seeing is absolutely incredible How
can we handle true images How can we see the containers how can we create a container How can we stop it How can we add a port How can we delete an image There are many things we are working with images and containers But this is not all I want to show you how everything behind docker works how it works how we can create content We are going to see that right now so far we have seen How we can manage images and containers in docker and the truth is that you are very interested But
what do you think if I tell you that there is something more interesting than this and it is the dock architecture we are working on ta ta but we don't know how this works internally And for that let's talk about the architecture Look, something you have to know is the heart of docker or also called docker demmo This is a docker server and basically it is the one that will allow you to in charge of everything that is container management you can execute you can create you can delete you can pause you can do everything
to a container thanks to the docker Demon the docker Demon is the heart of docker without it you cannot work with containers so that would be the architecture you have your docker Demon And how do you communicate with this docker Demon How we have been communicating with the heart of docker to be able to manage the containers and well we have done it thanks to a docker cive a docker client would be like that console that terminal with which we have been executing the commands but do not think that that terminal connects directly with that
joker demo there is something called Race ap it is an Api well We are working Or rather we are communicating with the heart of docker thanks to an Api and We do this from the terminal well you have Your terminal there in which you execute the commands and you for example do I know docker PS so what you do with an API you communicate with the docker heart and the docker heart It will be in charge of seeing the entire state of the containers and it will return it to you thanks to that API, that
is, we can communicate with docker Demon via http And that way we are going to go Well, we are going to be able to create containers, images, we are going to be able to manage them and we are going to Let's see very important topics at a time such as what networks and volumes are in Docker and Well, this is a fairly simple topic which I wanted to talk to you about and it was the architecture of Docker and I needed to know it. It is very important, the time has come to talk. of a
very interesting topic and it is the docker file But what is a docker file exactly what the hell is a docker file look at a docker file is a plain text file that contains a set of instructions that docker uses to build an image a docker file As it says here, it is a text file, which is going to have many lines, each line is going to do something, it is going to do something in particular because It is going to allow you to create an image, that is, in each line. We are going to
specify how it is going to happen. to build this image, we already know that it is an image that would be the template. Hey, look, you are going to tell him for each line how this image has to be built and look, the process to be able to create this file is very simple, basically it The first thing we have to do is create a file called docker file And in this docker file we are going to write the necessary instructions so that this image can be created So you have your docker file and How
can you transform from a docker file that is, from a file to an image You can do this using a command called build with the build command you will tell it that you are going to build that file or an image. Now that you have that image you can make a RAM so that that image becomes an instance of a container well This looks very interesting but we have to put it into practice so that it becomes much more interesting to be able to create a dockerfile the first thing we see is to locate ourselves
in some I in this case I am in cris and I'm going to do For eh I'm going to access desktop here the desktop I'm going to access my desktop and on my desktop I'm going to create a folder called docker or rather course docker is going to be called that's what I'm going to create my docker course folder and I'm going to access docker course docker course Well done I have absolutely nothing here and what I'm going to do is create a file called docker file well you can create a file from here from
the terminal or you're just going to visual Studio code you give it in file New file and you create the file called docker file well and that's it, in this case I'm going to do it from here I'm going to create a file called docker file Touch docker file ls and here we see docker file now what What I'm going to do is open this file docker file from visual studio code for this next file I'll go to Open folder I'm in cris okay Let's see let me see if I'm in cris okay let me
go here docker course select folder select folder and click on it It says that there are errors Well I'm going to enter the docker course desktop here and select the folder And if I select the docker course folder I will be able to see here a file called docker file well In this file we are going to write line by line each instruction necessary to be able to create an image from this file we are going to be able to create an image Well done and This will be quite simple first what we have to
write is from from ready from well but first what we will do is pause all the containers that we have active docker PS docker images good and I'm going to delete the image of ubun docker rmi ubun good Well I'm going to pause all the containers docker container Yes I'm going to pause delete them and now docker rmi ubun let's see docker PS less aa see docker container Yes do PS well it doesn't work for me in this case let's see docker container and well well then we have to pause everything we have to place
a docker stop for example we start with web 3 docker stop with ubuntu No here we have like Always app Always app Let's see let's make the work easier let's pause everything from here Look at the containers we are going to pause all delete well and the images we are also going to pause all of them Well here we can do this because we have installed docker of this but most likely it is that in a work environment We don't have to do it from the console well Like this I'm going to delete it from
here for easy, but I've been placing this. Well done. Now I wanted to delete everything we had so we could look and the first thing you have to do is place a from from ubuntu, for example two points, and you'll get it. let's pass the lest version here What are you doing Here we are going to indicate we are indicating we are going to indicate the image that we are going to use we indicate the image that we are going to use I am indicating Hey look I am going to use the Ubuntu image and
here we place it the leides version now we are going to execute a command here we have something called Ram that can be used to execute a command And I know that for example we are going to place an aptg update command and at the same time apt get install I am going to leave all this for you here in the description of this course with a repository a link that will take you to a G repository what else for example we can say cool get beim and git ready well what we are doing here
is installing one or another tool we are going to tell you install install install eh some Useful tools some useful tools well for this we put Ram which will allow you to execute some operation right Well here we put a Ram what else apart from r we are going to put a Word Dear this is very important is the space of the work inside the container, that is, what will be the work space that you are going to have? Inside this container, we are going to place an app, that is, when you convert this image
to a container, where the work space is going to be, I am going to indicate that the work will be in a folder called app here the necessary files will be saved to be able to work with this container ready now we can execute another Ran Command basically allows you to use many various commands the amount of RAM that you want and we are going to place it done and we say hello dock, something like this, look, hello dock, hello docker, okay, and we're going to save this here in a file called health. txt well
what we do is create a file we create a file a text file inside the [Music] contor Look you are creating a file you are executing a command First to install some tools in Linux then you are executing another Command to be able to write the Hello World message in the health file. txt and in case this file does not exist, it will be created. This is a Linux command. Well, what else are we going to put the port, for example, expose, and we are going to indicate that when this image is executed, it will
be exposed to port 80. This for possible connections and something last but not least we are going to put cmd cmd done now why we are going to use cmd This is going to be a default command well you can only have one cmd Unlike you can have several Ram that it will execute several commands well, this Command is a default command that should only be executed when this container starts well it starts and it will be able to be overwritten, that is, if you do not do anything in the docker Ram, this Command will
be executed But if You pass it some parameter, it will be able to be overwritten within this. I want you to keep that in mind. Here we are going to place this. This is an example container. Good, ready, and Here we are going to indicate it as an Entry point for the container. That's it. and to be able to run this entire docker file now and convert it to an image and that image to a container we will do it from the command prompt or from the terminal Better said we do an ls to see
that image well then we see the following docker build less ty we go to pass the name ubun to New the name of this image and we are going to put a dot on it. What we will do is build this image to be able to go from a docker file to an image it is necessary to put the docker build command on it and then we will pass the label less t It is a tag, it is a name that will be assigned to this image and then a dot, the dot indicates where that
file is located, we give it an enter and perfect, now everything that you are seeing on the screen is called layers, each of these It is a layer and in each layer there will be certain actions, let's say the actions, for example in the layer here, it is downloading such a Data, it is loading such a Data, here the from blocker is doing well, and each one that you see here, each one of them. These lines here are going to be called layers, they are the famous layers, the famous stages, ready, we are going to
Execute here, we are going to pause and well, in this case it is installing me, for example, it is in the layer in which the RAM command is being executed and I It is installing certain Linux tools, this was optional, this ram here but I'm still going to leave all these files in a github repository so you can download it and practice with it separately. If you want to learn git and github from scratch, I recommend you check out our course also available on our YouTube channel well here we have an error in the next
layer it tells me that well First I want to make sure blocker images here I don't have any image So let's check the file and look at this part we are going to remove the D so that you You avoid these problems, I'm going to leave you this file, this file in a repository here, just copy it, you can do it if you want, it's here, it's a tool, it's tools, well, again, we're going to run this from here, then, and we're going to do it docker build. men tunon Let's give it an enter now
s If now we review all this we make a docker images we see here the ubun image and it is the image that was just created and we have just created An image from a docker file in this way you can create the amount of images you want and you can specify everything you want well and good We are going to run this image to put everything into practice we place a docker Ram docker Ram men it men p port 7070 for the Host and 70 for the container the name of the image ubun New
and now we are going to pass it a command is Bin bash B bash ready enter ready We put docker Ram men it men p the name of the port of the machine the port of the container ubun ready for example we are going to do The following is true and now we execute another one or rather we are going to do an ls and here we see txt greeting perfect we see txt greeting and we do a Cat txt greeting Hello docker And if we go here to visual Studio code we saw the following
Hello docker O whether this Command is going to be executed Hello, docker is going to run, a hello txt file is going to be created, but why hasn't this example container been shown to me, do you know why you are overwriting it here? In other words, you are passing another command here, okay, so let's get out of this Look we are going to get out of this and we are going To place docker Ram but without this and it will be ubun to New 2 and the Port will be 80 80 70 80 we give
it an enter and Well here it gives me an error it tells me Well let's put it ubun to New Good ready Now if you place docker ram in an interactive iterative mode os p so that you can set the port and give it the name of the image now this is an example container appears Why Because you are no longer passing any separate command That is, when you pass it when you work with cmd cmd will allow you to execute a command as soon as the container starts but it has a defect it can
be overwritten and in this case if you pass it one more parameter That is another separate command this In other words , for example, Bin bash will no longer execute this cmd but it will be replaced by that Command that you are passing to it, but when you only put the docker RAM Command in it and you do not pass it any extra parameters so that you can overwrite cmd This is going to be executed here echoed to be able to print terminal This is an example container as we can see here well and this
is what I wanted to show you about the images docker PS docker well these are inactive docker PC well What we are seeing is super Interesting but what do you think if now we see an example of docker exec docker exec is also a very interesting command and what it will allow us to do is execute a command when we try to execute a container Look docker Ram docker Ram less d less less name my container is going to be called like this my container well my container and we are going to put a colon
on it well well enter in this case it is being downloaded in gex because we have deleted it a moment ago So it is simply going to download look what it is going to do It's simply, for example, we're going to do the following. This is a normal command. We know how this command works. The truth is, it's a run command in the background and here you pay the name, but what do you think if you want to execute a command inside this container? What I mean is to execute the same thing, the same thing.
We are only going to place my container 2 and here, for example, apart from everything we are passing to it, we indicate that we want to list the html files of this server, so for this we are going to place the Following we are going to put docker exec less it my container okay in this case we are going to see docker PS we have docker exec Well we are going to put docker exec we are going to put where it is is my container My container here we are going to pass it less it
to interact with this ls usr let's put it usr what else usr eng html tells me let's see let's put my container 2 Let's see give me a minute let's clean the console let's run ls ls again so we can Show good lr enginex enginex html ready good then here we have two files I had confused are 50x html and Index html if I do a ca Index html in this case it tells me no Ah of course well in this case it is showing me two files the first of them is for example 50
html and the Index html is inside this enginex folder so what you are doing is from the container that you have executed, let's say you are going to execute a command inside that container and To be able to execute a command inside a container you are going to use docker exec. you pass the container which you want to execute a command and then you pass it, for example, the ls command and this one here with this you are going to indicate that you are going to execute a command inside this container well this is something
very simple that you can also implement it in your projects Well ready we are working a little with docker exec a little docker file well let's not say that they don't have something in common but docker is going to allow you to execute a command inside a container which was something that I also wanted to mention to you Now I want tell you about a difference The difference between cmd and entry Point that you will also probably hear cmd is this part here We have seen a moment ago how cmd works, which will allow you
to execute a command as soon as you start the container, but it can be overwritten while entry Point is the same. Well, it is the same, but it will not be overwritten. In other words, if you You pass something apart from the Command You pass something else, a parameter is not going to be overwritten, it is going to continue there, it is going to continue and For that, what do you think if we see an example, we see an example for each one and we will do the following. Look, we are going to do the
following. Let's go. Let's go here to our terminal and we're going to do a ls. Here I see a docker file but we'll do the following. We're going to create a mkd folder that's going to be called example a good and we'll do CP docker file docker file example a ready ls well we'll do a ls and here we see docker file now we will do a RM docker file ls is no longer simply what we are doing the docker file example an oú you can simply go here to your file system and really well
There is no problem ready ls and we are going to create another MK folder example 2 example 2 m example 3 mkdir example 4 we are going to see three examples to be able to understand in detail the difference between cmd and entry Point I want you to understand it and that there is no problem So first we are going to go here to CD example 2 We are going to give it a touch doile in the same way we are going to put c two points to go back C example in the same way
points c example let's See well 2 3 it would be missing example 4 Here we are going to create another file that 's it folders I have my respective docker file then we will do the following we are going to open the docker course folder here in visual studio code we are going to delete this one and well I here in docker course I have four folders example 4 example 3 example 2s and we are going to work here with each one A docker file docker file from the example two folder we are going to
place a from and we are going to use an image for example the one from al well here well uh the latest version and here a very important command entry entry Point ready each Command that you execute in entry Point which is something new What we are seeing is that it will allow you to execute a command as soon as this image starts and well, we are going to tell you a fact done Hello world Hello world world with entry Point entry is ready now why I show you entry Point md because you will see
it in a docker file and you already know that Ram, you can have many rams, eye and Ram are commands that are going to be executed In order, they are layered. Unlike cmd and entry Point, which are executed as soon as the container starts. But there is a big difference between entry Point and cmd. I want to show you better with an example. We are going to place this in the docker file of the example 2 folder. In the docker file of the example 3 folder, we are going to place the same thing only and
here we are going to place cmd cmd and we are going to place it Hello. world with cmd Well, this is ready and now I want you to execute well, copy the same in the docker file of example 4 but first you place hello world with cmd and here, for example, you can place a hello world with entry Point, that is, we are going to use both at the same time entry ent we are going to place ent Point Well ready perfect We have the docker files here What do you think if we first start
with the docker file of example 2s this docker file is another separate one let's start with the docker file of example 2 for that we leave Let's go here we are going to make a ls CD example 2 well and I want you to execute the following Command docker build men t my image this is what it will be called my image one point ready you are going to build your first image from this docker file But this is going To be relatively simple well because it has a few docker commands Run my image enter
Hello world with entry Point so in the first example what we have seen is a hello world with entry Point cool here a hello world with entry Point What is the big difference that there is between running a hello world with entry Point for example look at docker Run my image and we are going to put an extra message say hello hello subscribe We are going to put it subscribe subscribe to my channel to my channel subscribe to the technology advance to the technology advance well enter Look here You see the following when you execute
entry Point you see the message Hello world with entry Point And besides, subscribe to the Channel, what this means is that no matter how much you pass an extra command, an extra parameter to the docker ram command, the message will always continue to be shown every time you put e Point But what do you think? If we do the same but with example three example three then look I want you to do the same with example three now This example three if you make a docker file Look you see here here we are working with
cmd well We are working with cmd no longer with entry Point Then we are going to do the same docker docker Run my image 2 that is, it will be my image number two and look Well, let's pause, we were missing Build the image docker build men t my image 2 let's see docker build men t Im 2 a I missed the point to tell you where the docker file is Now we are going to do the following docker Ram my image image 2 here everything is perfect Hello world with cmd But if I pass
it, for example, a parameter and I put it Join our community Join to our community community of free courses of free courses well enter let's see it tells me that we are going to put it recommends maybe the message is very long let's see docker Ram mayim 2 Hello world with c here docker PS we are going to put docker r+ 2 and simply Hello Good here I am cleaning my console and for example normally when you execute an image you can put it here for example Hello Here I have an error so to avoid
these errors The Command is going to be done Hello hello Let's place it Hello new enter okay and that's it docker Run image Hello new what we are doing is replacing this here This parameter here This Command with the command that we have here on CD ad difference that when we work for example in example two c example 2 we make a docker Ram it was [Music] called image 1 fact Hello test Hello test enter Look Hello world with entry Point and Hello test and AC difference you don't have to place a fact you simply
put Hol tes and look Likewise And this is the difference elto key point to understand the difference between an entry Point and a cmd is that in this case the entry Point is not not replaceable it is not overwritten While the CD and well this would be all but we would need to work with the last one the last example which is from CED example 4th well in this example I have placed it More than that you practice everything so that you can practice I am going to leave you this docker file as an exercise,
what you are going to do is basically build this docker file image and run it, that is your exercise, nothing more, but I left you here example four Example two It was to show you the same as example three and example four is already an exercise for you well That is like a gift and in this way it is very interesting to work with container images with a docker File with options with commands here in docker But now we are going to study in depth What is the Docker Hub, which is the very famous repository
that we have been talking about, is where the images come from. The image repository is a very interesting topic, but well, you already have the connection. Well, you should already know more or less What It is a repository if you have already mastered gu and gza or, well, you have been practicing with this tool, a repository would be like a hosting, so to speak, a place in which you will be able to host several things, several projects, and the most common example is github, which It is a repository of projects and these are going to
be managed by git here in dockerhub or rather docker also has its own repository and Well we are talking about docker we are talking about containers So dockerhub would be a repository not of containers it would not be a repository of docker images it is a docker hub image repository is a place where you can store all the docker container images, suppose you have 10 images why dockerhub manages or rather stores or hosts images and not containers The containers although we know they are instances of these images are the running images So it would be
best not to have images in containers Better said in a repository if these containers are going to be used when they are in production if they are instances they are images that are running then the images that are templates that are only used for reading It would be better if they were in a repository for what. For example, you have your application and you don't want to pass your application directly to your colleague on their computer. What you want to do is publish it in dockerhub in that magic repository of images. Well, now in that
repository. Not only will your friend be able to download your code and test it or rather he will be able to download your project and test it on his computer and it will work wonderfully because he is working independently in a container, but he will also be able to do your best. friend will be able to, your other friend and your other friend. In other words, you will have three friends who will use your application without any problem. And you no longer have to give each of them the application, you simply Publish it in docker
or in dockerhub an image and Well, you have that image hosted on dockerhub, each of your friends will be able to upload that dockerhub image and test it on their computer. This is the wonder that dockerhub has, it is an image repository. This looks very interesting. But what do you think if we take it? into practice and it becomes much more interesting to be able to register here at dockerhub. The first thing we want to do is go to the official docker page. Dockerhub. You type dockerhub and you will be able to enter here. I
have an account I'm just going to hit Login okay And this is a password that you can't see so I'm going to delete this part ready here I have my account in my case I have three test images okay and what we're going to do What to do is publish images in this repository once you have created your account and logged in I want you to go here to the console the terminal and first important we are going to do the following we are going to write inside this terminal once you have registered your account.
What we are going to do is write the following Command we are going to write docker docker login docker login is already there and here I want you to put your username and your password in my case my username I don't remember what it was and I don't remember my password either I have to check it so let's go I'm going to move this over here and well I'm going to see my username, my username in this case was Cristian Raúl So I put it Cristian Raul and I'm going to put my password and in
my case after putting the password it tells me that it has been possible to log in correctly. successful well we already have our data now what we are going to do is also place here in docker desktop well automatically you place here from the terminal here you have your data well well that is the first thing we would have to do now that we have done docker login We have already created our account in dockerhub. You already know what dockerhub is. It is the place where the images are. You have logged in. You have created
your account. First you have created your account. Then you have logged in. What we are going to do now is have an image. here docker images for example the image of image 1 the image that we have created New better here we have to see an image example a doer is here if I Remember correctly it was this one from here but well now with my image we are going to work with this this image Im 1 is not going to be the following docker name of the local image in this case we are going
to try with ubuntu New New is going to do the following for this image that you have locally you are going to put Cristian Raúl that is your username So that yes you have to put it correctly your username of your dockerhub Cristian Raúl you put it Cristian Raúl you put it Slash and the name of the repo which you want this image to be called I am going to call it for example eh ubuntu New repo 1 in this way well then What we are doing here is assigning a name to the name of
this repository, a name to the repository in which this image is going to be published, that is, we are going to publish this image in a repo and when we publish it in dockerhub, the name in which it will be published. Cristian raul ubun is going to publish a report This is the nomenclature to be able to name an image in a report this is very important now something very important is that you place a docker Push Cristian ra ubuntu New ubuntu New repo 1 you are publishing this image in docker one enter and that's
it, here everything is being prepared And well it is being published all this takes time but we will see it in a moment well and if we see the following we do one or rather we go here to our dockerhub account we reload Well and you here in your repositories in your dockerhub account in the repositories part you have to have a new repo in my case I have ubuntu repo 1 It is the repository that we have just published. We have just done the following. What we have just assigned to this repo from the
terminal is a name apart from a name. We have indicated that we are going to publish it with docker Push. What you do is publish your image. your image repository and to verify that all this exists we do Search Search and we put Cristian Raúl Cristian Raúl and again the name of the ubuntu repository New repo 1 in this way it tells me the c docker is missing here Search docker search what you do is search for that image in this case it is not official but here is my repository Here is my image well
it is perfectly ready Now if you want to download an image that I also showed you for example docker pool redis do lates so that it downloads the image from a database As is ris And if we make a docker PS docker PS Here we see, for example, docker images Here we see, for example, the image that we have in this case in dockerhub, the ub New image, the enginex image, the redis image and the other two images, well done. Perfect, then like this This is how we can work and we can download images, now
we can run those images with a docker RAM and there is no problem well. This is how dockerhub works more or less a little bit and the truth is that it is quite simple but good Now let's review what container inspection and monitoring is to be able to show you more or less how what I mentioned works. I have created a folder called example 5 in visual Studio code here we have two files, one my. html that has an html file which simply shows you a message and a paragraph then we are going to create
a docker file in this docker file what we are going to do is define how this image is going to be created again and for this we are going to work a little already with an image in ginex for example in latest latest And what else are we going to do the following that is going to be Exposed to port 80 and we are going to place a new instruction which is copy copy we are going to copy this file called my app pun html good Where to usr share shero let's put shero enginex html
good What is this myapp html is the file that you see here my app. html Then you are going to copy this file into the enginex folder, that is, inside the enginex container, ready, and you are going to copy it into this folder, well, this folder exists within enginex. This is a command that is also very interesting and very important. that you take it into account well then from this what we will do is go to our console and we will execute the command docker build eh men t my docker app docker app and we
will put a dot and that's it well in this case like this Why It has been created too quickly because this image was already downloaded from enginex, so very quickly but here you see my docker app of 188 MB a little heavy so we can monitor this application or this image first we are going to run this and let it be a docker container Ram less name my container container what else my test container for example we can give it To be in the background and with the ports for example 80 80 2.8 my docker
app Docker is no longer there PS and here we see for example that it was app well and for example we go here to our browser and we put local Host 8080 we can access the enginex server well and this is why because here in that case each request that you make from the machine that is port 8080 that is mapped to the machine will be It is going to communicate with the container now what would happen if I want to show the Index html file you would have to place it here for example Hey
myapp html is already there Look V here my app. html this is communicating with the container and the container is returning the file my app. html well because when creating this image we have indicated that it has to be copied and that's it ready that way we are working let's go here and well let's go over what is the monitoring which was what we would have to see for example docker inspect my container My test container container than this Here it was a command that we saw at the beginning well that basically helped you to
see the properties ready well For example here it tells me it has been created on a certain date not the path the arguments are enginex Men G demmon off the ID and well among other things For example, let's also place docker logs less F my test container what is it for l menu F my test container good This will help you see the logs in real time For example if you make a control here r control r control r control r control r here you will be able to see some logs ready look here some
logs appear it tells me that on April 24, 2024 on April 29 such a time well let's do this such a time it was accessed from such a computer such and this way you have made a get request and such Here we see the logs in real time, it is something a little interesting that you can also take into account another one that would be docker stats stats my container My test test container Well done and here you are going to see many things The truth is if you do an r se control here It
will also load, for example, well, what does all this mean? First, here we have the container ID, which is the identifier of the container. For example, also the name of the container, the percentage of cpu that is being used and the memory usage of the container. Here we see a limit also as a maximum and the memory what else eh the inputs and outputs well and here the Processes right But anyway we are going to pause control c this would be to see a little statistics and well If we want to execute a command d
Inside this container that also already We already saw it, it would be, for example, a docker exec minus it my test my test container my test container And I know, for example, an enginex minus sub Here is the version of enginex 1.25.5 l let's clean it up, let's talk about networks in docker well Networking is something very important in Docker and they are functionalities. It is a fundamental functionality that will allow you to communicate between containers as well as communication between containers and the outside world. Okay, you may wonder. Hey, but we have been communicating
containers and we have used a network. Yes, in Docker a network is created by default and you will be able to work under that default network, which we will see in a moment. Well, that would be the networks. But what do you think if I told you that you can also create your own networks? personalized, that's right. You can create a network, for example called the technology lovers network, then in that network called technology lovers you will be Able to indicate which containers are going to work under that network and only the containers that are
under that network will be able to communicate And this is quite interesting we are going to see it in practice here I am going to show you more or less the architecture here we can see two services and we can see how these two services are on the same networks for example here we see a network of these two microservices Here we see another network that is between these two microservices and these can communicate, these other two too And these other two too, these ones here unfortunately do not belong to the same network So they
will not be able to communicate well but Here we see quite a few examples and we are going to put everything mentioned into practice. You already know that all containers are going to belong to a network and that containers work with networks. We are going to see how we can create and list these. How we can manage them, first we have to go back to where we were in the docker course well until in the docker course it is in the docker course we can be ready well then what we are going to do is
a docker Network ls The docker Network Command is going to allow us to list all the networks in this course we are seeing many commands I recommend that you write down all the commands In other words, don't just see the course and write the same thing as me, see notes, investigate, buy what I'm teaching you, everything I'm showing you, buy it from other sources, search, read, use your intelligence. They can help you, they can also give you a lot of information. You can tell them to give you more examples, check the documentation, and that way
you practice. Because if you only write what I am doing and don't put it into practice, that is, you don't make other examples, you will probably find yourself forget And if you can Show this to other people it will also be useful So we are listing all the networks that we have And we have some by default the Bridget House not in this case it is that there are no networks well but the most important thing is the Bridge the Bridge bridget and Host, the first is the default network used by the containers when it
is not specified that you are going to use another network, each container connected to this network has its own virtual network interface and the Containers can communicate through this network, that is, in in a network there are containers and in that entire network those containers will be able to communicate then we have the Host well basically Host eh allows a container to compact directly with the network interface of the Host that is to say of the machine well eh the container does not have its own network but uses the computer's network well nothing more So
these would be the two types of networks Host and bridge by default But what if I told you that you can create your own network and customize it to your liking So let's execute The Command docker Network create my Network my Network so we are going to call it my Network ready So if we do a docker Network ls here you can see all the networks and here we see a call my Network we have just created what we are going to do next is execute a container, for example, any one in this network. Then
we are going to place docker docker inspect well, first we are going to do an inspect to our network docker inspect my Network well and for example here you can see some properties such as the ID, creation date, name and well What we are going to do next is run a container on this network so docker r minus minus name my container container no que s yo que S container 5 as several cones we have my container 5 minus minus Network To pass it a network and it will be the red my Network that we
just created, then we are going to pass it the image that would be enginex do this would be the docker command minus name the name of the container the network to which this container will belong and laag in this way we could be working we simply give it one enter and that's it, well, let's see that everything is perfect here, be careful if you open another terminal and put wsl or simply docker docker PS Here we see, for example, where it is, we see here we don't have it PS men a docker PS men a
for example Wow here we have a lot I think I have executed many well so what we are going to do is pause this we are going to pause and we are going to execute all this again but in detou mode which is what we needed to tell you so here we are going to put it at the beginning simply minus d ready mode but here let's run it with another name container 6 what do you think Now docker PS And here we have my container that is my container number six and what do you
think if we do a little inspec to this container docker inspect my container or rather of course Let me see my container 6 if we see the properties here we can see that it belongs to the network my Network if you see networks In other words, the networks we see that it belongs to the network my Network the network that we just created a moment ago well and in this way you You can create containers on a network and run containers on said network. That's it. This is quite simple. Now if you want to disconnect
this container from that network, you have to execute another Command. Do you know what the command would be? docker Network disconnect disconnect my My Network is already done docker Network disconnect my Network And what else are you going to pass the name of the container in this case my container was the container I don't remember very well Let's test if it was this one and yes That was So if you see here docker PS you see here my container docker inspect My container 6 my container number 6 and if we go to networks and look
this is changed to the bridge network by default it is no longer in the look rather it no longer has any network it Is no longer in the network my Network has just been deleted or rather disconnected, that container has been disconnected from that network using the docker Network disconnect command and if you want to eliminate a network, that is, you make your docker docker Network ls and you want to eliminate, for example, the network my Network, easy, you put docker Network RM and you put my Network this way you will eliminate the network my
Network of your computer broker Network ls where is it I don't see it it was just deleted well the network was just deleted ready this one It would be more or less a bit about network management in docker it is a very interesting topic But what do you think if you have data very interesting in your containers, you don't want to lose them. How would you save that data? For this, let's now see what the B mount volumes are. Let's talk about data persistence in Docker. Has it ever happened to you when you have your
container and you have very important data? It's that you don't want to lose them, whether it's a record in a table or a database or a particular file that you don't want to lose. So you don't want to lose that file and it happened to you that you delete that container and you say, "I didn't lose it, yes." Because you have not used volumes or bind mounts and we are going to see what the volumes are and what the bind mounts are which will allow you to persist data in docker we can also manage data
so here I put data management What are the volumes the volumes They are the preferred mechanism to preserve the data generated and used by Docker containers, that is, everything that you are going to generate in a container, when you delete it, you are obviously going to lose everything from that container. So the ideal would be not to lose the data. And to Well we can do it in two ways using the volumes AND using the bind mounts or also known as mounts but let's see the volumes first Why they are the preferred mechanism Look, I'm
going to tell you a little about the concept of bind mounts now that You already know what volumes are, I'm going to talk to you about by mounts. Linked mounts have limited functionality compared to volumes. Why is it good when you use a bind mount, a file or a directory will be saved in a directory? on the Host machine well Then unlike a volume the data or rather the volume is not going to be saved here I am going to show you a little image Look here you can see that we have a container and
here we have a volume and here we have a bind Mount So the bind Mount is going to be saved in the file system well, but be careful, the ideal would not be to save it in the file system, mostly for security reasons. So, imagine that you have users and there are their passwords, you want it. save on your computer Are you sure you want to save someone else's computer so that another person can access your computer and see your data Are you sure well I think that to practice or rather from my point of
view to practice the ideal would be to work with by mouns but for something in production for something much more real for a company companies are going to use volumes Why Because the volumes are not going to be saved on your computer in the file system the volumes are going to be saved in a space an area of docker so to speak well here we see a docker Area and here is the volume While the bind Mount is in the System files well file System So that would be the difference between a bind Mount and
a volume true it would be very simple But what do you think It seems that if we have carried out absolutely everything mentioned in practice, it looks interesting, right, and let me tell you that in practice it will be much more interesting now that you are clear about when you have to use izar b mounts and when volumes you know that a Mount B Mount is more appropriate for situations where you work with the Host, right? That is, where you have to have direct access to the Host and so on, and the volumes are a
little more appropriate when the persistence is in a production environment, well. So that's a little bit more or less the difference. Excuse me a little if I don't pronounce these terms very well, the truth is that my English is not very good, I'm working on it, I'm practicing English. So to all those from the system, absolutely, you are watching this video, you are from the systems, I recommend that you learn English, please, English, me too I'm learning English and well, I don't have a very good pronunciation but we're there and we're doing well. So we
have what the b mounts and the volumes are. What we're going To do is see several examples and for that we're going to do it within the docker course. we are going to create a a new folder mkdir mkdir is going to be called example se Here we are going to see what volume and mounts are ready then to start we are going to create within this same folder example 6 example 7 example 6 another folder called mongodb gu under Data well this is how it goes to call mongodb gu baj Data inside this folder
we are going to save it as a table and the database so to speak well then we are going to use an image of [ __ ] deb we are going to work with [ __ ] deb example if you don't know [ __ ] I must See Our course available on [ __ ] on our YouTube channel So let's put docker men d men less name my mongodb container container well my mong container that is, you put r men d men men my [ __ ] container Well done What else are we going to
put, it will be in detou mode, the important name, we are going to put less less my [ __ ] Deer and we are going to put less v and here in the minus V we are going to pass it by Mount, we are going to put the route first. Where will the by Mount [ __ ] be? I must Data, that is, where the path of the Mount folder will be and in that folder the container will be saved. For example, the database, the table, well in this case They would be collections because it
is [ __ ] deb [ __ ] deb Data two points and here I am going to put Data db then we are going to place [ __ ] do points latest well We are going to make this a little smaller and now we do give it a good enter First you are going to run this in a container in the background with the name [ __ ] container and you are passing it a B Mount, that is, you are indicating that in your file system you are going to have a folder called [ __
] of B datata is the one that we created a moment ago and here the elements of this container will be saved And in this case by default here I was missing the Slash Data deb by default [ __ ] deb saves its data here in a folder called Data db now this here We have to remove this Slash and we leave it like this. We are going to give it an enter and well in this case it is downloading and what it will do is run this image in a container And again a by
Mount we are going to save in the mongodb folder and a under Data in our file system the data that exists in The database if we now try with a docker PS we can see here that the container my [ __ ] db container is running and here we will be able to work directly with this container and be able to insert data in a database in that way when it comes to eliminating the container what we will do is pass that data that is in dat db to this B Mount that is on our
computer and that way when we run another container again we can load the data And to check everything I'm mentioning, we're going to do the following. Look , we're going to clean the whole thing. If you have any errors, run this. You can leave what you get here in the comments. Well, then I'll do it. first is to place docker exec less it in the background well in this case it is not in the background but to be able to interact with the ador my [ __ ] db mongodb container and we are going to
place b what will be useful to us blocker exc remember it is to execute some Command in the container then we simply place this and in this way we can Access the container we can interact with the container right Well then the important thing here is to execute the following Command [ __ ] [ __ ] sh in this way we will be able to interact with the console of [ __ ] and we will be able to save data because we will be able to create a database and save elements there in a collection
so Us bd Try with Us bd test we will tell you and we will create a database and we will use in this database we will be working in this database db users here it is a little different when you work with a non-relational database you usually work with collections in what is [ __ ] deb if you want to learn [ __ ] deb You are invited to join our free course available on this same YouTube channel mongodb from scratch d. insert users and we are going to pass some data such as a name
name and we are going to put Cristian Ramírez Well then we are inserting into the users collection that we are going to create, which is created automatically if not exists Well we can also put an insert many that is to insert several records at the same time here we are going to put another value julen julen julen olive well here another value We are going to put Saw that is fine db pun users good Now what we will do is dbf would not be db users pun F to be able to list everything and well
here we can see three records one that says Cristian another that says and another that says saw well what we have done is create a database we are going to put show cls show databases in it and we have created Well a database called test B in test b we have created a collection called users And it has three records so normally you when you pause this container Look let's pause this container first let's get out of this okay let's get out of where it is and we are going to place PS well here in
docker PS you can see the active containers But what do you think if I do a docker stop stop and we are going to place for example my [ __ ] [ __ ] db container well docker PS is no longer there and now if I delete it docker RM my [ __ ] deb My [ __ ] deb container either if I delete it I do a docker PS men a docker PS men a in my case nothing exists anymore I don't have any value I mean I no longer have any container I just
deleted the container which had the only thing I have is my B Mount I have it here in visual Stud code good Look I have a folder called mongodb Data at the moment it is empty good Maybe data will appear for you it would be ideal but At the moment it is empty, we are going to place this because we have not used it yet. So we are going to place CD [ __ ] under Data, for example ls, and here it would have to Show you if it shows you something, AC shows me nothing,
in my case it does not show me anything. but this does not mean that it will not work, what we are going to do is execute the container again as it was the same and you have to pass it the same bind Mount in this case the B Mount already has data And these data from B Mount is going to be passed to Data from by and it will find it well and since this image already exists the following well and we will do the following we will do the same docker exec except it my
[ __ ] My [ __ ] deb container and we will to place bash here we do a [ __ ] sh and we are going to show the databases show databases look and I want you to notice in the following database it says a database called test B test we a moment ago did a use B for test well This is quite interesting, a Moment ago we created a database called B for test and what do you think if we now make it a db users pun find dot find well in this case I
don't get anything let's see deb F Ah we have to indicate use deb test now yes test a moment ago est test and now users deb users let's see Ah no the other way around use B test This is the database test paes the database That you do have to put well the name well the database with which we were working is eh bd is here bd test well bd test So we are going to place here now yes db users fine well and now yes Now we see the new the same data from a
moment ago Cristian Ramírez Juli olive and olive are three records that we had seen a moment ago well We have seen all these records a moment ago eh And where are they stored well our B Mount folder that we can see here at the moment the truth is that this is usually not shown happen on my computer maybe on yours if it shows you but maybe it is hidden But inside [ __ ] deb Data the data is already fine because look when I execute I Can already load these elements So it is working correctly
yes We normally do an exit if, for example, you want to run another container but you don't load this volume. In other words, you don't pass this part here. You remove this volume. Normally, when you remove it, you don't know this saving process and when you delete you won't, you won't save that data in nowhere well And then we can save them locally on our computer the volumes would be the same only that it will no longer be locally but it will persist in another docker area We will see it in a moment well but
this example is very didactic but now let's see example using mysql as a database That is, we are no longer going to use in this case [ __ ] of B datata but we are going to create another folder mir you have there [ __ ] deata we are going to create another folder called and one under B we are going to work with my sql in this example 6 ready then what we will do is the same goer first Dj PS Well let me pause this one here my [ __ ] [ __ ]
db container and docker container let me make a docker container ready then what I'm going to do is run a Sql container less name I'm going to simply call it mysql container well my sql container and we're going to give it a volume a B Mount Better said it's going to be the same way as we passed it a moment ago it would be here it would be something like My sequal My squal db gu B Data something like it was here a moment ago Let's see let me see here in visual stud code ready
example 6 Here is myal gu under B my gu under B This is how myal gu will be under well then B Mount the data will be saved in this folder myal gu under db well once you pass it, for example, this here my gu under db you will pass it a colon And now where does my squal save the elements my squal can work differently than [ __ ] by is going to save it somewhere else in this case mysql saves it in bar bar lip my squal good my squal saves here in this
path you are saying I am going to create I am going to run a container and I am going to pass it a B Mount and in the my squ db folder I am going to save that data that database with that table and those elements and then here you pass it no here is the path where your data And you are going to save this data you are going to persist it here so that when you execute another Container this is loaded by default well and something very important well when you are working with
with my sql you have to pass it what is called mysql and a base Root and a base well these They would be like type environment variables well for this here because always when you execute or when when you work with a B sql you have to pass a password in this case we are indicating my equal Root password that is, the username is Root the password would be 1 2 3 4 in det Touch mode so that it runs in the background and the image in which you are going to execute is mysql well
this Command is quite simple you can practice and we simply give it an enter in this case it tells us that it cannot find the local mysql image So what it will do is download it from docker Hub once Once this image is downloaded what we will do is docker PS and well here we can see the mysql container well it is running it is currently enabled So we are going to clean the console and we are going to do the following docker docker exec minus it to do it interactively my squal container and well,
we are going to execute a bash command ready. Here we are going to place my squal my Sql, we are going to put it except that the default user is Root and we are going to give it a password . this case is 1 2 3 4 it's ready well my sql is a little simpler Well here it is Clear like this and well eh Clear So what we want is the following we are going to create a database create database it will be called What do you think test 1 yes we are going to
call it It is a ready if you put show databases databases you have here four bases five databases No here you have test a let's suppose that in this database test a you have a table records but I'm not going to do it questions of time, suppose that you have many tables, now you do not want to lose this database. Look, if you had not given it a volume, well, a B Mount. Better said, if you had not given it a B Mount, everything that you are going to create next would not be saved. but
since we have passed it a B Mount it will be saved So I can easily do the following I can do an exit I can do an exit and I can do a Docker docker RM menu F to delete it it does not matter if it is active myal with container container Ah it's my sequel My sql container ready let's put docker on it PS men oh there's nothing good so what we just did is delete the container well we just deleted a container If you go here it probably won't load anything like it did
for me well in my case the It is true that there are times when it loads, the truth is that it would have to be an update issue with my computer with docker but the most likely thing is that you will load the data. Likewise, as you can see when we have executed a container in the example of [ __ ] db the data is loaded in the same way as in My sequel that we are going to do next, for this we are going to execute the same thing again in mysql the same Command
the same data the same name of the container we give it an enter and now we go Let's put the same thing as a moment ago, not the docker exec less it my squal container B We give it an enter and good We're going to put the following here we're going to put my squal less u the user is Root and the password that we're going to put 1 2 3 4 That's it, we do a show Databases and here I have to Show test a and it is correct, the database has not been deleted
correctly Now what would happen if you, for example, do the same, you have to do the same but without a bind Mount good We are going to do a docker Run but from another container and we are not going to pass it a by Mount okay no we do not have to pass any by Mount we have to leave it as it is without by Mount okay we leave it like this and this is going to be my squel container 2 good now if we place a docker PS here for example Here we see two
containers I am going to make a docker exec for My sequal coner 2 good and I am going to place it here eh For example mysql men u Root men p 1 2 3 4 yes I I put a show databases here I am not going to see a database called test 1 here I do not see any database test 1 why because I am not loading a B Mount and now everything that you create here anything a table insert records if you delete this container you are going to lose absolutely everything And then that
is why it is used that is why the B Mount and the moun are used they are going to save everything locally well they are saving everything locally and It is perfect but now We must Identify a disadvantage of these bind mounts What is the disadvantage look everything is correct but you know what the only bad thing about the B Mount is that they have all the data exposed for the host computer all the data absolutely all and that is the problem to practice working with b mounts it would be correct but for something already
working something more productive the by moun would not be the best option the best option would be to work volumes to be able to persist the data in docker and no longer on our computer locally so for this we are going to work with volumes I am going to show you How you can create a volume So we are going to do the following Look docker volume docker volume ls with this you are going to list the volumes in this case These are three B mounts that we have created well they are b mounts but
when you put docker volume ls it will list all b mounts and volumes, as I told you, you have to know how to specify when it is a by Mount when it is a volume. If you see that this points to a local folder, it is a Mount and If it is not a volume, here we are listing one or another volume but we are going to create a volume now Docker volume volume create in this way docker Network create something very similar but this is docker volume create and it will be called db it
was not db gu baj [ __ ] but good Then we are going to put docker volume ls, I see db here but I am going to create another one called db gu low [ __ ] Now we do docker volume ls and this way we can see the new db volumes and [ __ ] I go to use db gu B mong okay This way we have created our first volume so every time we want to use volumes we are going to create one first that is, we are going to create that volume and
that volume Okay we are going to assign that volume to a container so that the information is not saved directly in the file system but is saved somewhere on the computer in which we can access the information only once through the ready container. So we are going to do the following docker PS - well docker PS we are going to put it docker docker container docker men F container well it was the other way around I think doer container docker container men F Pro Ah let's put do container Pro Yes Well here I was missing
men F and now yes well good docker PC Aha then We are going to do the following docker docker stop my squal we are going to place my squal container do St my squal container 2 and that's it Now yes docker container room Yes done this way we have just eliminated the containers that we had That's it then what we are going to do is create a container and we are going to pass it the volume that we just created. Then I am going to place it boker Ram minus d minus minus name [ __
] [ __ ] container simply like this minus minus Mount when you want to pass a volume to it you can normally pass it with the flag less less Mount well crs crs Equal and here we are going to pass db gu which is the name of the volume then we are going to put dst which here would be the destination well it means destination and we are going to pass it equal Data de by we put [ __ ] the name of the image well Look we are executing this Command docker Run men d
the name of the container less less Mount crs deb [ __ ] primo crs is going to specify the name of the volume which is going to be mounted in this case it is db gu b [ __ ] and then dst indicates the destination within the container where the volume will be mounted, in this case the volume that will store your Data will persist, the data will be mounted inside Data deb. Well done, what is Data deb? the default storage where [ __ ] deb saves its data we give it an enter and that's
it blocker PS and we can see that it is running let's do a docker exec less it [ __ ] container B ready we do here a [ __ ] sh well and we put Us or simply ls to show show databases to show the databases and well we are going to create a use it will be called bd test bd test we make a db users users users point insert in the same way the insert and we pass it a value in this case just a record to the collection name colon my name Cristian
Ramírez so we just inserted a record and to check this d. users F Well ready we do an exit to get out of this and we put docker RM men F and we are going to put [ __ ] container to delete this ready well it has just been deleted but you will wonder And where the hell does this keep me from here This where is it well the volume that we just created no docker volume ls well here it is m is the volume but it is not anywhere In your file system it is
in docker so we can call this volume without any problem when it comes to making a Ram no and we put here in the same way the minus minus Mount and you give it the volume if now you do the docker exec in the same way and you put it here for example [ __ ] and you put here users pun find well First you have to tell it that you are going to use this and then a db users pun find and there you can see the registry as you can see the volumes and
the bind mounts are almost the same but the big difference is where they store the values the by Mount will store it inside the computer from the post While the volume is going to be stored somewhere in the docker container or somewhere in docker. Better said well, then this would be a bit of the examples of the bind mounts and the volumes, I hope the difference is clear to you. Likewise, any If you have any questions, you can leave them here in the comments box. Now everything we have seen is great. But what if I
told you that there is a tool that will allow you to define this and multiple containers with these properties and execute it With a single Command? We are going to see that right now, let's talk about a very interesting tool docker compos What is docker compose docker compost It is a tool that will allow you to work with multiple containers Look We have been working at the moment or we have been working with one container for example What do you think if I told you that there is a tool that will allow you with a
single Command to create several containers at the same time, great, right? Imagine that you will no longer have to go through each image executing a do Ram command with the ports specified and what Other volumes, networks can be a little tedious, it really helps you a lot to practice But it can be a little tedious So docker compost is this tool. It is a tool in which you are going to define a file similar to docker file but docker file is to create a docker compost image It is a tool to create multiple containers you
are going to create a docker compost file with an iml extension and here you are going to indicate absolutely all the services that you are going to create if you want to have 10 20 30 containers the necessary amount You will you have to specify in that file and with a command you will be able to execute that entire file and all the containers you need will be created. It looks very interesting and here we see a little of the architecture we see here a docker compost Here we see that it is connected a network
Here we see three containers the volumes well and we can create all this using the docker compost tool we have to see it in practice since this looks very interesting now that you know what docker compost is and what we are going to use it for we are going to see some examples First I want you to go Here we are going to go back and we are going to create a folder in progress docker called example 7 mkdir We are going to create a new folder called example 7 okay Let's do the following CD
example 7 okay Let's clean this up let's to create a Touch docker compost iml This is the in that case this would be the structure the nomenclature to be able to create a comp iml file and this jum extension is always important now we are going to open this within vis Studio code Well it is no longer necessary because here we have it Where it is we have it here in example 7 docker compost iml And Here we are going to define the following well as well as the docker file a docker compost file and
it has to follow a certain structure So first what you always have to do in a file docker compost is to define what is called the version currently the version is 3.8 well we are 2024 the version of docker compost is 3.8 docker compost is a tool we know that it is a tool it will allow you to run several containers at the same time well So first you have to Define version 3.8 Now you have to define the services well here the services They would be like the Services containers and you have to be
very careful with the spaces here you have to give it a Tab well a Tab and we are going to write the name of the service first we are going to define What It seems like a service for the database, I'm going to call it db colon and we're going to put another t this is like a Tab, you give it an enter and a t well image and we're going to put the following my sql My sql do pun latest I want you to make sure of something, in this case I'm going to use
docker docker deop and I'm going to delete all these volumes that we have here I'm going to delete Everything I have here I'm going to delete the volumes I'm going to pause Well I'm going to pause the containers I'm going Let's delete them eh I'm going to delete the volumes too and I'm going to delete the images the images ready This well I don't do it from the terminal to save time But as I say it would be advisable that you do it from the terminal Now here you are going to happen the database service
this would be the database service and you are going to pass it mysql then you are going to define some variables for this image and we are going to start with environment the first of all we are going to start with environment environment well here It is like a name and a value well here first we are going to pass mysql my sql gu under Root and under password and we are going to pass example for example what else my sql My sql My sql and under database and the name of the database that it
would be my database can also be defined well in this case probably you can also define it like this Look mysql under user two pun user well This way it can also be defined well we are going to do it this first way it depends On the version I'm going to do it To make this version we would have to review the documentation and for this version we are going to put it like this sql Root password and here we are going to put it example the password for the root user is going to be
example the user we are going to put user my squal in under database two points my database ready We are going to place volumes volumes Well we are going to have a volume called and a low Data well that is going to save me in bar Well whatever I have in bar lip mysql ready volumes no this one did have to carry well So what are we doing we are defining a service that has an image the image is my squal sides and we are defining environment variables which are the properties such as the user
password and the database then we are defining a volume and it is and is here mysql is going to belong to the volume good ok to have your volume called db Data ready and now we are going to define something that can also be done here, which is the networks networks. In this case I am going to indicate that the network to which it is going to belong is to backen and in this way we finish to create our first service which is the database service now What do you think if we want a service
for the web application let's do this type of a format document format document and that's it Well let's eliminate this for the moment and well Let's add here as comments so that you can better guide yourself so that you don't get lost. We are going to put it here, for example, service, service for the database, well, service for the database, ready and Here we are going to put it as a service, service for the web application, service for the web application and here for the database I am going to copy this here and control V
now we have to define another service you In this way you can have the number of containers that you want, in this case I have first defined the service for the base of data This is a container that is going to be executed now I am going to execute I am going to write another one and it is the web service which is basically the service for the web application and what I am going to assign is the following we are going to place eh image the image is going to be enginex ng ng next
Alfine good alfine engine and Well we are going to tell it that it is going to depend depends on and we put db good Define in this case we are defining that the web service towards db that is, the web service is going to depend This one here, that is, it will depend on this one here on the data. Obviously, this does not mean that if this one is not executing, it will not work. It will not simply depend on the data. And that this one will always be executed first. which is deb and another
more important thing than what we would have to load is the following, first I am going to remove this part from here well and I am going to add under depends on something called ports we are going to map the ports 808 2.80 8080 is the port of the Host and 80 of the container in the same way you can map ports here well but I am simply doing it for what it is we then under volumes we are going to indicate html and under volume we are going to create a volume called html and
well and it that I have in usr share we are going to put sh sh html I am going to save it in this volume well and then we are going to have another volume also Of configuration config under volume and well whatever I have in what it is etc ngd which is a file configuration I am also going to save it here in config vol it is used to save htmls and the other to save the configuration files but well these are simply volumes that we are defining under volumes we are going to create
the networks and I am going to indicate that this is going to belong to the Front network and at the same time it will belong to the backen network so that in this way it connects the web service to the same network as the database Because the database belongs to the backen network and Well we are indicating that eh enginex is also going to belong to the network so to speak cu it is going to belong to the frontend network and also to the backend network ready OK now something very important that I also want
you to keep in mind is that outside of this outside of this outside of this we are going to define something that are the volumes volumes the volumes to define a volume we are going to define everything that we just created html volume config volume and deb Data and here its colon like this Okay ready and below these volumes we are going to place networks networks And we are going to define it in frontend and backend well then what we have been doing here is the following first we have defined the volumes and the networks
ready and now we are here creating a service that is going to run as a container is the service database that is going to use the mysql image, we are defining some environment variables, such as, for example, the password for the database and the user, we are indicating what the volume that will be We are going to use And this data we are going to save in this volume the network to which it belongs And in the same way with web we are indicating that this service is going to use enginex as an image it
will depend on the db of this service which means that The first one will run this service here, the ports will be 8080 for the Host and 80 for the container. And these are the volumes that will be used and belong to both the database network and the Front network. Ready We have our docker compost iml file so what we will do is the following we are going to go here create and we are going to place docker docker compose app men d detou mode ready We give it a Docker compose app men d so
that all this runs and as you can see here you see that it is downloading images it is running well Let's give it a minute here it tells us that the version is obsolete Which version have we put see a minute Let's put the file here version 3.8 well well well anyway it has surely changed normally but fine when we run docker comp app men d What does it mean First this is the command docker compose app is the main command of docker let's see Oh I know what happened is that the command was like
this docker app men d like this app men d in this way but it is already running and it works fine. It is docker compost in this way or also in this way but well what docker compost does is the main command to be able to interact with the docker compost tool that is going to help us. allow running multiple containers then we put app the app property indicates that you are going to start running the services the services They are going to become containers and unless d is in the background, that is, the current
terminal is not going to block you, that's it and you can see here it Tells me the following Network example 7 backen Network example 7 frontend the config volume db datata html volume and here the container is running and they are already started if we give it docker PS I can see here if I give it docker PS docker PS me I will be able to see two containers here, the first is from mysql and the other from enginex. What do you think if we are going to put docker PS back on it and do
a docker inspect, for example, on the container here, docker inspect on this container here, if we give it a docker inspect here we can see the following first we see that this is example 7 Front that is, it belongs to the front well or you can see what other property we can see here we can see let's go up and see the next let's see the next the name is example 7 web 1 good This is the name of the container that is, this is the name of the web good as you can see here
Here is the creation date Here is the ID what else are we going to download let's go down a little more and see other properties Like for example the volume the volume we have the volume html volume We have here volume Data true here we also have the destination in the same way for example here we have the config volume And we can go down and we see here the networks we have that belongs to the networks of both the backend and the Front network ready we are in this way inspecting each container and in
this way you can insert data you can delete a container and you realize that when it comes to executing it will be the same way Well ready This is the powerful tool called docker compost and this is more or less the structure of the file, I'm also going to leave you all this whole folder here in a github repository so you can talk. Remember that in the same way if you want to learn gid github you can see our course available in our YouTube channel ready this would be a little what docker compost is now
that we have seen practically all the topics in this course I want to add a Gift Voucher a gift a small gift this course and it is the topic of multi multilayers in doc We know how We can work with a docker file and what are the layers of a docker file for example Here we see in the example two files The example we also see several layers this would be the most complex example that we have seen well What we are going to do now is work with docker files but with multilayers multistage basically
When you work with multilayers this means that you are going to have multiple stages well This is a technique that will allow you to reduce the final size of the images by building multiple stages within the same docker file basically What is multistage? It is a technique that will allow you to reduce the final size of the images, that is, in a blocker file you are going to create an image but by applying a technique called multistage build, what it will do is reduce the final size of those images. and this is very useful when,
for example, you have multiple dependencies for this, let's see an example, let's go to the terminal here, let's make a docker PS well docker PS and there is something that I haven't taught you yet how to work with docker compost, look with docker compost app men d app men d you can say raise them with the containers but with docker docker const const down what you do with docker const down is Delete all the creators that have been created, that's it, that is, you are going to delete All the containers that you have created with
docker compost down docker PS it is no longer docker compose app men d so that they are created again And if you want to pause a container it is docker compos stop docker comp stop db for example ready and you are pausing a container if you want to delete a container by example docker comp rmdb you delete good well let's pause comp rmdb it asks if you want to delete it and you say yes Now docker compost RM helps you delete a container docker compost stop to pause one docker compost down to delete all containers
that are running good and well This is a little bit of docker compost some commands that I wanted to show you Now let's get to the good part of what we were in the multilayers for this we are going to go back and we are going to create another folder called example 8 This is the final example of the course let's go to do an ls we are going to access the example 8 folder and we are going to create a file called docker file docker F inside docker F we are going to add the
following code we are going to go down a little and we are going to go to example 8 first we are going to define what next from from not do pun al as Bu bien What are we doing here the first thing we are doing is the first stage stage 1 the first stage build we are building a web application with the name build we are assigning a name to this stage we are going to give it We assign a name to this stage, to this layer, to this stage, ready, then we are going to
indicate work Where we are going to work from, that is, we indicate the work directory, all the commands are going to be executed Within this work directory in the container and Now we are going to place the following copy app app, that means that I am going to copy the files from the app folder of this context, that is, from the system, to what is the container's App. This is what I am going to do. Ready, let's place it here. to place the following ready then after this what we will do is the following we
are going to place to define the stage 2 stage stage 2 stage stage 2 or simply the new stage we start a new stage in the image in next okay then First we are downloading not and then we are going to do the following from enginex two fists alfine and this is going to be called final That is, we already have two images, the first of Not and then the one of engine, this one is called bu and this one is called final, this is the construction stage and this is the final stage well and
we are going to place the following here I have a code and I am going to place it we are going to place a copy less less from build What does this less less from build mean that you are going to place it we are copying the files generated from the build stage well which were placed in the app directory we are going to place it here in usr share enginex html Or you from this stage here that you have build or from this build stage which would be the Note you are going to copy
Those files that you have saved in the App here you are going to pass them to usr share enginex html that is, what you have the data that you have in one image you are going to pass it to another and here we are Establishing as a small dependency right and that's it so what we are going to do now is expose the port expose 80 we are going to expose the application to port 80 and finally we are going to do the following we are going to execute a command here I have the command
anyway and it is the command that tells you what it is going to do is start enginex but In daemon mode so that the terminal appears fine And then we do it What we are doing is working with multiple stages, it is a technique that will allow you to reduce the size of the images. This is because first you download this image from Note and you are going to call it as build, then you indicate the working directory and it Otherwise now you download another image and it will be called end and now you no
longer have to download another image again you will simply use the one you have from build you will pass the data that the app has you will pass it here well and then we will tell you that this entire application is going to be exposed to port 80 of the container, ready, perfect and well, this would be all we are telling you, now continue, we put a cmd command, execute as soon as all of this starts and so that we can test this, we are going to go here to the I finished what better than
to try truth doer PS we are going to do a docker docker docker compose down to first download everything we had to see CD points CD example 7 first I am going to go back to example 7 I am going to place a docker compose down to eliminate everything what I had doer PS men a good Now we go back To example 8 again and now yes So we are going to put doer build men ty I am going to put my web app and I will put a point I am going to put web
I will put a point but good before executing this and so that you understand me better I want to do the following example look let's go here I have two files I have a folder called app and I am going to copy it here and well we are going to create a docker here we are going to place here outside of this well On the desktop we are going to look for docker course and in docker course we are going to copy into example 8, here I am going to leave all this attached to you
in a github so you can review it, look and so that you understand me better I am going to show you here which is an app, an Index html and a style.css well what we will do here is basically the following the working directory is app is here and then I am going to copy what I have to the working directory app in the container then what What I am going to do is what I have here, this Note image, what I am going to do is Download another image, well the one that is enginex
and now these files from the build stage that alfine has, that is, not, what I am going to do is copy The files that are in the app folder would be Index and there is the CSS point but from Word we are going to transfer it to the enginex folder and what we are going to do is check that all this is working well if you have any questions you can leave it here in the comments box well then what we are going to do next is the following docker docker build men t my web
app dot enter and the entire image should be building well Here it is going through several stages and we have to wait until everything is ready created satisfactorily, we are going to place a docker docker image ls to list the images and here we see my web app and we see here, for example, enginex well and what I am going to do is the following docker Ram less detou That is, detou mode p 8080 2.80 less less name my container we are going to place my container eh simply web we are going to place web
the container and now we are going to indicate the following web my my p my web app since this is the name of the image my web app we give it a enter and that's it docker PS Here I have this container up so what We will do is the following since we have this container up we are going to do the following we are going to do a docker exec men it web ls usr shad Well we are going to put shad shad ng next html good If I give here in docker exec to
execute a command in a container a ls usr sh engine html If you go to the visual studio it is the folder which has the App files of this image so if you notice we see here Index html and style.css And what do you think if we want to see the content of all this to be able to see the content what we can do is a Cat Cat for example an ls or the same thing ls It's okay only that now we put it Cat you can see the content of the html. Likewise if
you give it Cat again but you put style.css you can see the styles. Well done and in this way we can see how we have built an image and we have let's say we are making another image depend on the other and on In this way we are more or less seeing the use of multiple stages, so examples like these you can find many on the internet. Likewise, I am going to leave this entire repository here in the Comments section so you can download it and practice with it. Congratulations, you just learned docker. in record
time But before before before you leave, please don't leave yet, there is something very important that I want to tell you. Join our community of advanced technology. I invite you to follow us on our social networks, both on Instagram and Tiktok. Facebook and technology. advance the links I will be leaving them here in the description of this same course and something also very important is that we have courses on a platform called udem well here we have courses on backen development on fronten development and well you are invited to join our courses Don't forget to
subscribe to our YouTube channel and very importantly let me know in the comments box what other courses you would like for this channel what courses you would like what you would like to learn for 2024 and remember start learning now because technology advances and so do you