Docker Fundamentals Day 1/40:

Praful DhawalePraful Dhawale
4 min read

What is Docker:

Docker is an open-source platform that automates the deployment, scaling, and management of applications within lightweight, portable containers. Containers package an application and its dependencies together, ensuring consistency across different environments, from development to production. Here are some key points about Docker:

  • Containers: Docker containers are isolated environments that include everything needed to run an application, ensuring consistency across deployments.

  • Docker Engine: The runtime that builds, runs, and manages containers, handling Docker's core functions.

  • Docker Hub: A cloud-based registry for finding and sharing container images, offering a large collection of pre-built images.

  • Dockerfile: A text file with instructions on building a Docker image, specifying the base image, software, and configuration.

  • Images: Read-only templates for creating containers, including the application and its dependencies, reusable across environments.

  • Portability: Containers can run on any machine with Docker, ensuring consistent application behavior across environments.

  • Isolation: Docker uses containerization to isolate each container from the host system and other containers, enhancing security and resource management.

  • Efficiency: Containers are more lightweight and efficient than traditional virtual machines because they share the host system's kernel and resources, resulting in faster startup times and lower overhead.

Overall, Docker makes it easier to develop, deploy, and run applications consistently and efficiently, making it a popular tool in modern DevOps practices.

Docker Architecture:

Docker Architecture Explanation:

Overview

  1. Docker Host:

    • Docker Daemon:

      • The Docker Host is called so because it runs the Docker Daemon, which is the server part of the Docker Engine's client-server architecture.

      • The Docker Daemon is a long-running service that does the heavy lifting and is the brain of the Docker platform.

      • It provides API access for interaction through Docker clients.

  2. Docker Clients:

    • The client side of the Docker Engine, which can be:

      • Docker Command Line: The CLI tool to interact with the Docker Daemon.

      • Docker Desktop: GUI-based client for Docker.

      • Custom applications that developers might code to interact with the Docker Daemon directly.

  3. Containers and Container Images:

    • Under the control of the Docker Daemon on the Docker Host.

    • Containers: Lightweight, standalone, executable packages that include everything needed to run a piece of software.

    • Container Images: Immutable files that contain the source code, libraries, dependencies, and runtime needed to run an application.

  4. Registry (Hub):

    • A public or private store for Docker images.

    • Examples include Docker Hub, where images can be pulled or pushed.

Docker Commands and Processes

  1. Pulling Images:

    • Command: docker pull

    • Description: Downloads Docker images from a registry to the Docker Host.

    • Process: The Docker client communicates with the Docker Daemon, which pulls the images from the registry.

  2. Building Images:

    • Command: docker build

    • Description: Creates Docker images on the Docker Host using a Dockerfile.

    • Process: The Docker client sends the Dockerfile to the Docker Daemon, which builds the image according to the directives in the Dockerfile.

  3. Running Containers:

    • Command: docker run

    • Description: Runs a container using a Docker image.

    • Process: The Docker Daemon uses the image to create and start the container, adding a read-write layer to the image to allow data storage within the container.

  4. Pushing Images:

    • Command: docker push

    • Description: Uploads Docker images from the Docker Host to a registry.

    • Process: The Docker client instructs the Docker Daemon to push the image to the specified registry.

Lifecycle Management

  • Containers can be stopped, started, and managed throughout their lifecycle.

  • Images can be created, used to run containers, and pushed to registries.

Summary

  • The architecture remains consistent regardless of the number of hosts, images, or containers.

  • At a high level, the key components are the Docker Daemon, Docker clients, containers, container images, and registries.

This explanation provides a overview of Docker's architecture, the components involved, and the commands used to interact with and manage Docker environments.

Containers V/S Virtual Machines

Containers

  • Lightweight: Share the host OS kernel, resulting in smaller sizes and faster startup times.

  • Isolation: Provides process-level isolation using namespaces and cgroups, but less isolation compared to VMs.

  • Performance: Near-native performance due to minimal overhead.

  • Resource Efficiency: Uses fewer resources as they don't require a full OS for each container.

  • Portability: Easily portable across different environments (development, testing, production).

Virtual Machines (VMs)

  • Heavyweight: Each VM includes a full OS along with the application, leading to larger sizes and longer startup times.

  • Isolation: Strong isolation between VMs as each runs a separate OS instance.

  • Performance: More overhead due to the need to virtualize hardware resources.

  • Resource Usage: Consumes more resources because each VM runs a full OS.

  • Portability: Less portable compared to containers due to larger size and complexity.

Summary

  • Containers are ideal for microservices and applications that require fast deployment and efficient resource usage.

  • VMs are suitable for running multiple different operating systems on the same hardware and providing strong isolation for applications.

For your Reference: -

What is Docker

Docker architecture

Docker Commands and Processes

Containers V/S Virtual Machines

Thank you for reading this article. If you liked it, please follow.

3
Subscribe to my newsletter

Read articles from Praful Dhawale directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Praful Dhawale
Praful Dhawale

DevOps Engineer has to investigate and resolve technical issues, provide level 2 technical support, perform root cause analysis for production errors, build tools to improve customer experience, and develop software to integrate with internal back-end systems