Docker is the solution that is climbing right now. You have certainly heard about it lately.
This article aims to help you to understand the basics of Docker.
So Before starting let's explain briefly what's Docker.
What is Docker?
Docker is a computer software used for virtualization but it's not a virtual machine.
In fact the difference between them is that Docker and Linux containers do not behave in the same way as a VM.
A virtual machine isolates an entire system (its OS) and has its own resources, however in the case of Docker the kernel will share the resources of the host system and interact with the container (s). Technically, Docker is not a VM, not the least, but in terms of use, Docker may be related to a VM.
Launch an environment, and isolate the components of this container with the components of our hosts, this is what Docker knows how to do! It does so very well, and remains a much more efficient alternative to VMs (equivalent use)
Why use Docker and not a VM?
Docker is more faster due to the mecansim of sharing the host OS unlike VMs which uses their own OSs and resources. this will make the host more slow.
Docker use only Linux which help to have more secured applications.
Can i use Docker on Windows?
Yes, using Docker on windows OS is possible but with embedding it in VM which uses Linux OS because as we said before Docker works only on Linux.
Docker Architecture
Docker uses a client Server architecture.
The Docker client communicate with the Docker daemon which is responsible for building, running and distributing the Docker containers.
This communication is done throught REST API , over Unix Sockets or network interface.
The Docker client and daemon can run on the same system or remotely.
The Docker daemon
The Docker daemon ( dockerd ) listens for Docker API requests and manages Docker objects such as images, containers,..
The Docker Client
The Docker client ( docker ) sends commands to dockerd which carries them out.
The Docker client is able to communicate with more than one daemon.
Docker registries
A Docker registry stores Docker images.
Docker Hub is a public registry that anyone can use.
It's configured to look for images on Docker Hub by default.
You can also run your own private registry.
when using docker pull and docker run commands, the required images are pulled from your configured registry.
when using the docker push command , your image is pushed to your configures registry.
Docker Objects
There are differents objects such as: images, containers, networks, volumes,plugins..
In this section we will focus on the most important objects that you must know as a beginner.
Images
An image is a read-only template containing some instructions for creating Docker container.
Often, an image is based on an other image but with some additional customization.
For example, you can build an image which is based on ubuntu but installs the apache web server and your application, as well as the configuration details needed to make your application run.
You can create your own images or only use those which are created by others and published in a registry.
To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed
to create the image and run it.
Each instruction in a Dockerfile creates a layer in the image.
When changing the Dockerfile and rebuilding the image, only those layers which have changed are rebuilt.
Containers
A container is a runnable instance of an image.
It can be created, started, stopped, deleted or moved.
A container is defined by its image as well as any configuration options you provide to it when you create or start it.
Services
Docker run will start a single container.
With Docker service you manage a group of containers from the same image. you can scale them (start multiple containers) or update them.
docker service create is used to create instances (called tasks) of that service running in a cluster (called swarm) of computers (called nodes).
For example:
docker service create --name MY_SERVICE_NAME --replicas 3 IMAGE:TAG
creates 3 tasks of the MY_SERVICE_NAME service which is based on the IMAGE.TAG image.
Aucun commentaire:
Enregistrer un commentaire