0% found this document useful (0 votes)
3 views

Devops ♾

Docker is a technology that enables developers to package applications and their dependencies into portable containers, simplifying deployment across different environments. Key components of Docker include the Docker Engine, Docker Images, Docker Containers, Docker Registry, and built-in networking features, which enhance efficiency and scalability. Docker's portability, resource efficiency, and ease of collaboration make it a game-changing tool for software development.

Uploaded by

suresh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Devops ♾

Docker is a technology that enables developers to package applications and their dependencies into portable containers, simplifying deployment across different environments. Key components of Docker include the Docker Engine, Docker Images, Docker Containers, Docker Registry, and built-in networking features, which enhance efficiency and scalability. Docker's portability, resource efficiency, and ease of collaboration make it a game-changing tool for software development.

Uploaded by

suresh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

What is Docker?

Docker is a technology that allows developers to package their


applications and their dependencies into small, portable units, called
containers. These containers contain all the necessary software and
dependencies to run the application, making it easily deployed and
run on any machine. It makes Docker software development and
deployment simple and efficient, helping to quickly build, ship, and
run applications.

🚀 Key Components of Docker Architecture


1️⃣ Docker Engine
The Docker Engine is the core component that allows you to build, run,
and manage Docker containers. It comprises the following:

Docker Daemon:

The background service that runs on the host machine.

Responsible for managing Docker containers, networks, volumes, and


images.

Listens for API requests from the Docker CLI or other tools and
executes them.

REST API:

Provides a programmatic interface to communicate with the Docker


Daemon.

Enables developers to manage containers and resources remotely or


via automation tools.
For example, commands like docker run or docker stop interact with
the daemon via the API.

Docker CLI (Command-Line Interface):

The primary way users interact with Docker.

Allows you to execute commands like building images (docker build),


running containers (docker run), or stopping containers (docker stop).

2️⃣ Docker Images


Docker Images are read-only blueprints used to create Docker
containers.

An image includes everything the container needs to run:

Base OS (e.g., Ubuntu, Alpine).

Application Code (e.g., Python, Node.js).

Dependencies (e.g., libraries, runtime tools).

How are Docker Images Built?

Use a Dockerfile, which is a text file that contains instructions to build


an image step-by-step.

For example:

FROM python:3.9 # Base image

WORKDIR /app # Set the working directory

COPY . . # Copy application files

RUN pip install -r requirements.txt # Install dependencies

CMD ["python", "app.py"] # Default command to run

Build the image using: docker build -t my-app .

3️⃣ Docker Containers


A container is a running instance of a Docker image.

Containers are:
Lightweight: They share the host OS kernel rather than running a full
OS, saving resources compared to Virtual Machines (VMs).

Isolated: Each container runs in its own namespace, meaning


processes, file systems, and networking are separate from other
containers.

Example Workflow:

1. Build an image: docker build -t my-app .

2. Run a container: docker run -d -p 8080:80 my-app

3. View running containers: docker ps

4. Stop a container: docker stop <container-id>

4️⃣ Docker Registry


The Docker Registry is a centralized repository where Docker images
are stored, shared, and distributed.

Popular registries include:

Docker Hub: The default public registry.

Amazon Elastic Container Registry (ECR): AWS's private registry for


Docker images.

GitHub Container Registry: A part of GitHub for storing container


images.

Workflow:

1. Build an image locally: docker build -t my-app .

2. Tag the image for the registry: docker tag my-app username/my-
app:latest

3. Push to a registry: docker push username/my-app:latest

4. Pull the image on another machine: docker pull username/my-


app:latest

5️⃣ Networking in Docker


Docker provides built-in networking to connect containers and
services securely.

Network Modes:

Bridge: Default mode for standalone containers. Containers


communicate via the host but are isolated from external traffic.

Host: Containers share the host’s network stack directly.

Overlay: Used in Docker Swarm or Kubernetes for container


communication across multiple hosts.

Example of Bridge Network:

Run two containers:

docker network create my-bridge-network

docker run --network my-bridge-network --name web-server -d nginx

docker run --network my-bridge-network --name db -d mysql

The containers can now communicate with each other using their
container names (web-server, db).

💡 Why Docker is Game-Changing


1. Portability:

Docker containers are lightweight and portable. You can build an


image once and run it on any OS or cloud platform (as long as Docker
is installed).

This solves the "it works on my machine" problem.

2. Resource Efficiency:

Containers share the host kernel, consuming less CPU and memory
than Virtual Machines, which require an entire OS for each instance.

3. Scalability:

Docker makes it easy to scale applications horizontally by creating


multiple container instances of the same image (e.g., for load
balancing).
Example:

docker run -d -p 8080:80 my-app # Run one instance

docker run -d -p 8081:80 my-app # Run another instance

4. Ease of Collaboration:

Teams can use Docker images to standardize development and


production environments, reducing inconsistencies.

🔗 Analogy
Docker Images are like blueprints for a building.

Docker Containers are the houses built from those blueprints, running
in isolation.

The Docker Engine is the builder, making it all happen.

The Registry is like a storage warehouse for blueprints, ready to be


shared or reused.

You might also like