DevOpsStep by step guide about docker image build

Building Docker Images - A Step-by-Step Guide with Example

Docker is an open-source platform that enables the creation, deployment, and management of applications within lightweight, isolated containers. It provides a consistent and efficient way to package software and its dependencies, ensuring that applications run reliably across different computing environments.

What is Docker?

Docker is an open-source platform that enables the creation, deployment, and management of applications within lightweight, isolated containers. It provides a consistent and efficient way to package software and its dependencies, ensuring that applications run reliably across different computing environments.

Docker containers share the host OS kernel, making them more lightweight and efficient than traditional virtual machines.

Docker Architecture

Key Benefits

Docker Components

path
dockerfilefile
Required

Text file containing instructions to build a Docker image. Each instruction creates a new layer.

path
imageartifact
Required

Read-only template containing application code, runtime, libraries, and dependencies. Used to create containers.

path
containerruntime
Required

Runnable instance of an image. Has a writable layer on top of the image for runtime changes.

path
registryservice

Storage and distribution system for Docker images. Docker Hub is the default public registry.

path
docker-daemonservice
Required

Background service (dockerd) that manages Docker objects. Listens for API requests from CLI.

Installation & Configuration of Docker

To install Docker Engine on a new host machine, it is important to first set up the Docker repository. Once the repository is configured, you can proceed with installing and updating Docker using the repository.

Set up the repository

It provide instructions to set up the necessary repository and prerequisites for installing the Docker engine based on the operating system (OS) in use.

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  $ sudo apt-get update
  $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin