40 days of Kubernetes: Docker Fundamentals
Tags: docker, fundamentals, kubernetes, cka
Published: 2024-06-28 16:14:18

To understand Kubernetes, we should understand the concept of containers.

In the traditional way of development, the application deployment in local environments such as development and testing worked fine but would fail when promoted to production. The **"it works on my machine"** problem was never-ending.
When analyzed, the reasons behind the failure were mostly due to environment misconfigurations and missing dependencies or libraries etc. 

To solve this problem, we use **containers**

What are containers?
Containers are packages of software providing an isolated environment with all the necessary libraries, dependencies, application code, and the operating system required to run an application making sure that the application is running in the same way irrespective of the host operating system. The purpose of containers is to build-ship-run the code.

Unlike virtual machines, which has its own Infrastructure, OS, binaries, dependencies of its own where the chance of resources being underutilized are very high; Containers are lightweight environments that include only the required components that is required by the application. Containers are isolated but they share some of the resources and infrastructure of the host.

**Docker** is a platform that carries out containerization by building, running and shipping the tasks.

**Docker File**: A set of instructions that are required for building docker image.
**Docker Image**: Its a template packaged with necessary software's and dependencies.
**Docker Container**: It's a running instance of a Docker image.

The Key commands of Docker are: 

- _docker build_: This command builds a Docker image based on the Docker file.
- _docker push_: This command pushes the created image to a Docker registry.
- _docker pull_: This command is used to pull the image from the registry to the desired environment.
- _docker run_: This command creates and runs a container from the pulled image.

**Docker Architecture:**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lauo572aybxz7jq0evhl.png)

**Docker Client** is the interface using which users interact with Docker.
**Docker Daemon (DockerD):** All the commands issued by the docker client are received and executed by Docker daemon. It is the most important service that runs in the background managing the containers.
**Docker Host:** It is a component of docker architecture that is responsible for running one or more containers.
**Docker Registry:** A Docker registry is a storage for Docker images. They can be pushed to a registry before deploying them to various environments.
**Container Runtime:** The component that is responsible for running containers.
When a client request is sent to Docker Daemon, it interacts with container runtime to build an image based on Dockerfile and then the image is pushed to Docker registry and pulled from it when required.

We will learn in the next step to create a Dockerfile, build an image, and execute our first containerized application. 

Reference: https://www.youtube.com/watch?v=ul96dslvVwY