๐๐ซ๐๐ก๐ข๐ญ๐๐๐ญ๐ฎ๐ซ๐ ๐จ๐ ๐๐จ๐๐ค๐๐ซ
Docker Architecture: Client-server model, Docker daemon, REST API, and containers. Efficient, scalable, and flexible for modern app deployment.
Published Aug 1, 2024
Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface. Another Docker client is Docker Compose, that lets you work with applications consisting of a set of containers.
๐๐จ๐ฆ๐ฉ๐จ๐ง๐๐ง๐ญ๐ฌ ๐จ๐ ๐๐จ๐๐ค๐๐ซ:
๐Docker Engine:
The core of Docker is the Docker Engine, which is responsible for building, running, and managing containers. It includes a server, a REST API, and a command-line interface (CLI) that facilitates communication with the Docker daemon.
๐ Docker Compose:
Docker Compose is a tool for defining and running multi-container Docker applications. It uses a YAML file to configure the applicationโs services, networks, and volumes, allowing for easy management of complex multi-container setups.
๐ ๐๐จ๐๐ค๐๐ซ ๐๐๐๐ฆ๐จ๐ง:
The Docker daemon (
dockerd
) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.โข Docker daemon runs on host O.S.
โข It is responsible for running containers to manages docker services.
โข Docker daemon can communicate with other daemons.
โข It is responsible for running containers to manages docker services.
โข Docker daemon can communicate with other daemons.
๐ ๐๐จ๐๐ค๐๐ซ ๐๐ฅ๐ข๐๐ง๐ญ:
The Docker client (
docker
) is the primary way that many Docker users interact with Docker. When you use commands such as docker run
, the client sends these commands to dockerd
, which carries them out. The docker
command uses the Docker API. The Docker client can communicate with more than one daemon.โข Docker users can interact with docker through a client.
โข Docker client uses commands and REST API to communicate with the docker daemon.
โข When a client runs any server command on the docker client terminal, the client terminal sends these docker commands to the docker daemon.
โข It is possible for docker client to communicate with more than one daemon.๐ ๐๐จ๐๐ค๐๐ซ ๐๐จ๐ฌ๐ญ:
โข Docker client uses commands and REST API to communicate with the docker daemon.
โข When a client runs any server command on the docker client terminal, the client terminal sends these docker commands to the docker daemon.
โข It is possible for docker client to communicate with more than one daemon.๐ ๐๐จ๐๐ค๐๐ซ ๐๐จ๐ฌ๐ญ:
๐ ๐๐จ๐๐ค๐๐ซ ๐๐จ๐ฌ๐ญ:
โข Docker host is used to provide an environment to execute and run applications.
โข It contains the docker daemon, images, containers, networks and storages.
โข It contains the docker daemon, images, containers, networks and storages.
๐ Docker Networking:
Docker provides a range of networking options for connecting containers, allowing them to communicate with each other or with external networks. Docker creates default bridge networks, but users can define custom networks as needed.
๐Docker Volumes:
Docker volumes provide persistent storage for containers. They allow data to be shared between the host and the container, as well as between different containers. Volumes are a way to manage and persist data generated by Docker containers.
๐ ๐๐จ๐๐ค๐๐ซ ๐๐ฎ๐/ ๐๐๐ ๐ข๐ฌ๐ญ๐ซ๐ฒ:
โข Docker registry manages and stores the docker image.
โข There are two types of registries in the docker:
a) Public Registry: it is also called as docker hub.
b) Private Registry: it is used to share image with in the enterprise.
โข There are two types of registries in the docker:
a) Public Registry: it is also called as docker hub.
b) Private Registry: it is used to share image with in the enterprise.
A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker looks for images on Docker Hub by default. You can even run your own private registry.
When you use the
docker pull
or docker run
commands, Docker pulls the required images from your configured registry. When you use the docker push
command, Docker pushes your image to your configured registry.๐ ๐๐จ๐๐ค๐๐ซ ๐๐ฆ๐๐ ๐:
An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image which is based on the
ubuntu
image, but installs the Apache web server and your application, as well as the configuration details needed to make your application run.You might create your own images or you might only use those 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 you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.
Ways to Create an Image:
a) Take image from the docker hub.
b) Create image from docker file.
c) Create image from existing docker containers.
a) Take image from the docker hub.
b) Create image from docker file.
c) Create image from existing docker containers.
๐ ๐๐จ๐๐ค๐๐ซ ๐๐จ๐ง๐ญ๐๐ข๐ง๐๐ซ๐ฌ:
A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.
By default, a container is relatively well isolated from other containers and its host machine. You can control how isolated a containerโs network, storage, or other underlying subsystems are from other containers or from the host machine.
A container is defined by its image as well as any configuration options you provide to it when you create or start it. When a container is removed, any changes to its state that arenโt stored in persistent storage disappear.
โข Containers hold the entire packages that is needed to run the application. In other words, we can say that the image is a template and the container is a copy if that template.
โข Container is like a virtual machine.
โข Images becomes container when they run on docker engine.
โข Container is like a virtual machine.
โข Images becomes container when they run on docker engine.
Example Docker Run Command:
When you run this command, the following happens:
- If you donโt have the
ubuntu
image locally, Docker pulls it from your configured registry, as though you had rundocker pull ubuntu
manually. - Docker creates a new container, as though you had run a
docker container create
command manually. - Docker allocates a read-write filesystem to the container, as its final layer. This allows a running container to create or modify files and directories in its local filesystem.
- Docker creates a network interface to connect the container to the default network, since you didnโt specify any networking options. This includes assigning an IP address to the container. By default, containers can connect to external networks using the host machineโs network connection.
- Docker starts the container and executes
/bin/bash
. Because the container is running interactively and attached to your terminal (due to the-i
and-t
flags), you can provide input using your keyboard while Docker logs the output to your terminal. - When you run
exit
to terminate the/bin/bash
command, the container stops but isn't removed. You can start it again or remove it.
ย