Docker engine :
Docker engine refers to the host machine where we have installed the docker. Docker Engine consist of three different component- Docker Deamon, REST API Server and Docker CLI.
Docker Daemon : It manages the background services such as images, Containers, volumes and networks.
REST API : Rest API server talks to the deamon and provide the instructions.
Docker CLI : It is a command line interface that help us to write our command which then will be taken by the REST API and then sends to Docker Daemon to process that.
Docker CLI can be on the same host system or another system(our Laptop).
How to Run Docker CLI on Different Machine
# Syntax
docker -H=remote-docker-engine-url:< port >
# Example : Run nginx
docker -H=remote-docker-engine-url:< port > run nginx
Docker Containerization Concept :
Once we create a container the question should comes in our mind that how does these container will be seperated from each other and docker host machine. Docker uses Namespace to isolate the workspace.
ProcessID Namespace :
Conceptually there is no hard isolation between the process running on Child System (Container) and underline Host.
process running inside the container are the process running on host machine. However ProcessID can't be same.
Namespace help us to separate the processID between the host machine and container. For each process in child system (Container) it will create a separate process ID on host machine. However Container does not have any information about the host machine process and hence it thinks that it has his own root process and it's an independent system.
If we list all the process inside the container and Host Machine What we will get is all the process running on container will also be listed on host machine with different ProcessID.
It indicates that the underline host machine and container share the same system resources such as memory and CPU. By default there is no restriction on how much resources can be consumed by host system and container. Due to this we can come to a situation where container may end-up utilizating all the resources in underline host machine.
Control groups :
cgroups are use to controls the amount of hardware resources that can be allocated to the container.
# cgroups:
# --cpus: limits the amount of cpu that container can use.
docker run --cpus=.5 ubuntu
# -- memory: limits the amount of memory that container can use.
docker run --memory=100m ubuntu