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.
- 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.
- A virtualized environment created during runtime that actually runs the image.
- The container actually runs the image in its own virtual environment.
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.
- With Docker, the application layer is virtualized.
- Docker Containers run/start faster!
- Images are smaller.
- 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.
- When you install Docker, you install the Docker Engine under the hood.
The Docker Engine is comprised of three components:
- Responsible for pulling images
- Responsible for managing images and containers
- Responsible for interacting with docker server
- This is the client that is responsible for executing
- This is the client that is responsible for executing docker commands
- 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.
- Responsible for pulling images and managing container life-cycle.
- Responsible for persisting data in containers when a container stops running or something goes bad.
- Responsible for configuring networks for container communication
- The functionality of building docker images.