Beginner's Guide to Containers: Day 1 of 40daysofkubernetes

Beginner's Guide to Containers: Day 1 of 40daysofkubernetes

ยท

4 min read

What is Container ?

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.

In simple words, A container is a bundle of Application, Application libraries required to run your application and the minimum system dependencies.

Containers vs Virtual Machine

Containers and virtual machines are both technologies used to isolate applications and their dependencies, but they have some key differences:

  1. Resource Utilization: Containers share the host operating system kernel, making them lighter and faster than VMs. VMs have a full operating system and hypervisor, making them more resource-intensive.

  2. Portability: Containers are designed to be portable and can run on any system with a compatible host operating system. VMs are less portable as they need a compatible hypervisor to run.

  3. Security: VMs provide a higher level of security as each VM has its own operating system and can be isolated from the host and other VMs. Containers provide less isolation, as they share the host operating system.

  4. Management: Managing containers is typically easier than managing VMs, as containers are designed to be lightweight and fast-moving.

Why are containers light weight ?

Containers are lightweight because they share the host operating system's kernel and libraries, providing isolation for the application and its dependencies without needing a full operating system, resulting in a smaller footprint compared to traditional virtual machines.

Why do we need containers?

Containers are portable, support quick scaling, improve version control, and streamline development, testing, and deployment, making it easier to build, ship, and run applications reliably across different environments.

Docker

Docker is a containerization platform that lets you easily build container images, run containers, and push them to container registries like DockerHub and Quay.io, although other platforms like Podman and runC are also available.

Docker Architecture

Docker LifeCycle

There are three important things,

  1. docker build -> builds docker images from Dockerfile

  2. docker run -> runs container from docker images

  3. docker push -> push the container image to public/private registries to share the docker images.

Some Terminologies (from Docker docs)

Dockerfile

Dockerfile is a file where you provide the steps to build your Docker Image.

Docker daemon

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 client

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 Desktop

Docker Desktop is an easy-to-install application for your Mac, Windows or Linux environment that enables you to build and share containerized applications and microservices. Docker Desktop includes the Docker daemon (dockerd), the Docker client (docker), Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper. For more information, see Docker Desktop.

Docker registries

A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look 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, the required images are pulled from your configured registry. When you use the docker push command, your image is pushed to your configured registry. Docker objects

When you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects. This section is a brief overview of some of those objects.

Images

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.

Resources I used

  1. Video ->

  1. Documentation

Thank you for reading my blog

ย