Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fixes #2 with added examples and diagrams #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 65 additions & 15 deletions ebook/en/content/001-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

## What is Docker?

Docker is an open-source platform that automates the deployment, scaling, and management of applications using containerization technology. It allows developers to package applications and their dependencies into standardized units called containers, which can run consistently across different environments.
Docker is an open-source platform that automates the deployment, scaling, and management of applications using containerization technology. It allows developers to package applications and their dependencies into standardized units called containers, which can run consistently across different environments.

### Key Concepts:

1. **Containerization**: A lightweight form of virtualization that packages applications and their dependencies together.
1. **Containerization**: A lightweight form of virtualization that packages applications and their dependencies together.
**Example:** Suppose you have made a dish and you want your friend who is far away from you to have a taste of it. You can not send the prepared dish, but you can send all the ingredients that have been used to prepare the dish. Basically, you are containerizing your whole dish and shipping it to your friend.
2. **Docker Engine**: The runtime that allows you to build and run containers.
3. **Docker Image**: A read-only template used to create containers.
4. **Docker Container**: A runnable instance of a Docker image.
5. **Docker Hub**: A cloud-based registry for storing and sharing Docker images.
3. **Docker Image**: A read-only template used to define the initial filesystem state of new containers.
**Example:** If Docker was a traditional virtual machine, the docker image can be compared to the ISO used to install the VM. This is not a robust comparison as **Docker differs from VMs** in terms of both concept and implementations, but it's a useful starting point to understand images.
```
+--------------------+
| Docker Image |
| |
| (Read-only) |
| |
+--------------------+
|
| Creates
v
+--------------------+
| Docker Container |
| |
| (Writable) |
| |
+--------------------+
```
4. **Docker Container**: A runnable instance of a Docker image. Think of a container as a lightweight, portable package that includes everything needed to run an application—code, libraries, and system tools.
Containers are isolated from each other and the host system, ensuring that they run consistently across different environments
5. **Docker Hub**: The most popular cloud-based registry for storing and sharing Docker images. In Docker Hub, we deploy source code and **image** of our application.

## Why Use Docker?

Expand All @@ -27,10 +47,10 @@ Docker offers numerous advantages for developers and operations teams:

Docker uses a client-server architecture:

1. **Docker Client**: The primary way users interact with Docker through the command line interface (CLI).
1. **Docker Client**: The primary way users interact with Docker is through the command line interface (CLI).
2. **Docker Host**: The machine running the Docker daemon (dockerd).
3. **Docker Daemon**: Manages Docker objects like images, containers, networks, and volumes.
4. **Docker Registry**: Stores Docker images (e.g., Docker Hub).
4. **Docker Registry**: Stores Docker images (e.g., Docker Hub, ECR, ACR, GCR).

Here's a simplified diagram of the Docker architecture:

Expand Down Expand Up @@ -70,15 +90,34 @@ While both containers and virtual machines (VMs) are used for isolating applicat

1. **Build**: Create a Dockerfile that defines your application and its dependencies.
2. **Ship**: Push your Docker image to a registry like Docker Hub.
3. **Run**: Pull the image and run it as a container on any Docker-enabled host.
3. **Run**: Pull the image and run it as a container on any Docker-enabled host.
Simplified diagram of Docker container lifecycle
```
┌───────────────┐
│ Build Image │
└───────────────┘
┌──────────────────┐
│ Push to Registry │
└──────────────────┘
┌───────────────────┐
│ Pull Image & Run │
└───────────────────┘
┌───────────────────┐
│ Container Running │
└───────────────────┘

```

Here's a simple example of this workflow:
Here's a simple example of workflow:

```bash
# Build an image
docker build -t myapp:v1 .

# Ship the image to Docker Hub
# Ship the image to Docker Hub (registry)
docker push username/myapp:v1

# Run the container
Expand All @@ -95,11 +134,22 @@ docker run -d -p 8080:80 username/myapp:v1

## Use Cases for Docker

1. **Microservices Architecture**: Deploy and scale individual services independently.
2. **Continuous Integration/Continuous Deployment (CI/CD)**: Streamline development and deployment processes.
3. **Development Environments**: Create consistent development environments across teams.
4. **Application Isolation**: Run multiple versions of an application on the same host.
5. **Legacy Application Migration**: Containerize legacy applications for easier management and deployment.
1. **Microservices Architecture**: Monolithic applications can easily be broken down into smaller independent services where each service can be developed, deployed, and scaled individually in its own container.
**Example:** E-commerce platforms with separate services for payment, inventory, and customer management can be deployed and scaled independently using Docker.
```
+-----------------+ +------------------+ +------------------+
| Payment Service | | Inventory Service| | Customer Service |
| (Docker) | | (Docker) | | (Docker) |
+-----------------+ +------------------+ +------------------+
```
3. **Continuous Integration/Continuous Deployment (CI/CD)**: Streamline development and deployment processes. To ensure that the environment is same for all stages of development, Docker containers are used in CI/CD workflows.
**Example:** Suppose a software development team uses Docker to create a CI/CD pipeline where the same container image is used for building, testing, and deploying an application. This consistency helps avoid issues related to the environment.
3. **Development Environments**: Create consistent development environments across teams.
**Example:** Developers working on a web application can share a Docker image that contains all necessary dependencies and configurations (specific versions), ensuring that everyone is working in the same setup.
4. **Application Isolation**: Run multiple versions of an application on the same host.
**Example:** A company might run different versions of its web application for testing and production simultaneously in separate containers, allowing developers to test new features without affecting live users.
5. **Legacy Application Migration**: Containerize legacy applications for easier management and deployment.
**Example:** A financial institution may have an old monolithic application that they migrate into Docker containers. This migration allows them to modernize their infrastructure while maintaining compatibility with existing systems, making it easier to deploy updates and scale as needed

## Conclusion

Expand Down