docker what and why
What is Docker?
In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they're running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application
Image and container
Image is a single file containing all the dependencies and all the configuration required to run a very specific program.
This is a single file that gets stored on your hard drive and at some point in time it you can use this
image to create something called a container.
A container is an instance of an image.And you can kind of think of it as being like a running program.Right now all we really need to understand is that a container is a program with its own isolated set of hardware resources.So it kind of has its own little set or its own little space of memory has its own little space of networking technology and its own little space of hard drive space as well.
What happen when we run a docker run hello-world command
When we ran the command docker run Hello world.
That meant that we wanted to start up a new container using the image with the name of hello world the hello world image has a tiny little program inside of it whose sole purpose sole job is to print out a message ,That's the only purpose of this image.
Now when we ran that command and it was issued over to the docker server a series of actions very quickly occurred in the background.
The Dockers server saw that we were trying to start up a new container using an image called Hello world.The first thing that the Dockers server did was check to see if it already had a local copy like a copy on your personal machine of the hello world image or hello world file.
So the docker server looked into something called the image cache.Now because you I just installed docker on our personal computers that image cache is currently empty.
We have no images that have already been downloaded before.So because the image cache was empty the Dockers server decided to reach out to a free service called docker hub the Dockers hub is a repository of free public images that you can freely download and run on your personal computer so server or reach out to dock or hub and said hey I'm looking for an image called Hello world.Do you have one. Of course the Dockers downloaded this.
Hello world file and stored it on your personal computer.In this image cache where it can now be rerun at some point in the future very quickly without having to read download it from the dock or hub. So essentially we downloaded it over here Lexa.
After that the Dockers server then said OK great I've got this image and now it's time to use it to create an instance of a container.And I remember what we just said about a container a moment ago an instant container is an instance of an image.
Its sole purpose is to run one very specific program so the Dockers server then essentially took that single file load it up into memory created a container out of it and then ran a single program inside of it and that single program's purpose was to print out the message that you see right here.
So that's pretty much it.
Comments
Post a Comment