Launching 40 Days of Kubernetes: First Day Insights ๐Ÿš€

Launching 40 Days of Kubernetes: First Day Insights ๐Ÿš€

Fundamentals of containers and Docker:

ยท

3 min read

Before diving into Kubernetes, let's understand containers and how they work! ๐Ÿณ

1. Why do we need containers? ๐Ÿค”

In traditional development, applications may work locally but fail in testing or production due to:

  • Configuration mismatches

  • Library and package differences

  • Code dependency conflicts

Containers solve this by packaging the app code with all its dependencies, ensuring consistent runs across environments.

2. What is a container? ๐Ÿ“ฆโœจ

A container is a lightweight, portable package that includes:

  • Application code

  • System dependencies

  • Application libraries

As long as Docker is installed, the container can run on any OS.

3. What containers bring to the table? ๐ŸŽ

  1. Effective resource management ๐Ÿ’ผ

  2. Cost savings ๐Ÿ’ฐ

  3. Reduced manual efforts ๐Ÿ› ๏ธ

  4. Consistent across different environments(Dev,staging,prod)

  5. Isolated environment for applications (base image)

4. What is Docker? ๐Ÿณ

Docker is a platform that implements containerization and helps to build , run and ship the container. It effectively manages the container lifecycle.

5. VMs vs. Containers

Virtual Machines (VMs):

  • Virtualize the OS layer

  • Provide complete isolation and enhanced security(Guest OS)

  • Typically large in size (GBs)

Containers:

  • Virtualize the application layer

  • Offer portability and effective resource utilization

  • Share host OS resources, ensuring cost savings and isolation through base images

6. Container Shared Resources ๐Ÿค

Containers share these from the host OS:

  1. Filesystem: Shared file system

  2. Namespace: Isolates running container processes

  3. System Calls: Host OS kernel handles system calls from containers

  4. CGroups: Limits and controls CPU and RAM usage for containers

  5. Networking: Facilitates container networking

7. Docker Workflow ๐Ÿ”„

Key components:

  • Dockerfile: Blueprint for building Docker image.

  • Docker image: Read-only template ready to run as a container.

  • Docker registry: Stores all the images.

8. Docker Commands

  • docker build: Build a Docker image.

  • docker run: Run a container from an image.

  • docker push: Push an image to a Docker registry.

  • docker pull: Pull an image from a Docker registry.

9. Docker Architecture ๐Ÿ—๏ธ

The flow:

  1. Docker client interacts with Docker host.

  2. Docker daemon(on Docker host) receives requests from Docker client and manages images, volumes, networks, and containers.

  3. Docker registry stores built images, ready for shipment to any environment.

When the Docker Daemon (dockerd) receives a build request from the client, it interacts with the container runtime to build the image based on the Dockerfile. Once built, the image can be pushed to a Docker registry if needed.

10. Image vs Container?

Image: Image is the actual package we built using Dockerfile, it's a read-only format.
Container: Running environment of our image is container.

Stay tuned for more updates as we progress through the #40DaysOfK8s challenge! Happy learning, keep sharing! ๐Ÿ“š๐Ÿ’ก

ย