Tomislav Kraljic
Posted on June 19, 2021
What is Docker?
Docker is a containerization tool that enables developers to easily pack, ship, deploy and run their applications.
If your application requires the installation of Node.js, Express, MongoDB, and Redis, you have to manually install these on your machine. Depending on the OS, this can get tedious and many things can go wrong.
However, with Docker, all those configurations, services, dependencies are installed and all you have to do is run the image in a container. You no longer have to directly install anything yourself.
Image vs Container
Image
- File that holds the source code, configurations, dependencies, tools, etc needed to actually run the program
- This is the actual package/artifact that can be moved around.
Container
- A virtualized environment created during runtime that actually runs the image.
- The container actually runs the image in its own virtual environment.
Docker vs Virtual Machine
To understand Docker, we need to understand the Operating System and it's layers.
The application layer is everything you interact with. This would include any desktop applications, IDE's, internet, etc. This application layer runs on top of the Kernel.
This OS Kernel handles device management, memory management, resource management, and accesses computer resources. It communicates with the hardware that includes the RAM, CPU, etc.
Docker
- With Docker, the application layer is virtualized.
- Docker Containers run/start faster!
- Images are smaller.
Virtual Machine
- A VM virtualizes both the application layer AND Operating System Kernel.
- A VM can run an operating system on any host machine. However, with Docker, you can't.
Docker Engine
- When you install Docker, you install the Docker Engine under the hood.
The Docker Engine is comprised of three components:
-
Server
- Responsible for pulling images
- Responsible for managing images and containers
-
API
- Responsible for interacting with docker server
-
CLI
- This is the client that is responsible for executing
docker commands
- This is the client that is responsible for executing
docker commands
Docker's Architecture
- Docker uses a client-server architecture.
- Docker's client (CLI) talks to the Docker server(daemon) which does the heavy lifting of building, running, distributing your containers.
- When we talk about the daemon, it is simply a process called dockerd running in the background waiting for any requests by the API
- The docker daemon (dockerd) listens for Docker API requests and manages docker objects(images, containers, networks, and volumes).
- A daemon can also communicate with other daemons to manage the services.
Docker Server's Responsibilities:
-
Container Runtime
- Responsible for pulling images and managing container life-cycle.
-
Volumes
- Responsible for persisting data in containers when a container stops running or something goes bad.
-
Network
- Responsible for configuring networks for container communication
- The functionality of building docker images.
Posted on June 19, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 20, 2024
November 19, 2024