Skip to content

Commit

Permalink
Merge pull request #9 from bobbyiliev/updates-for-2024
Browse files Browse the repository at this point in the history
Updates for 2024
  • Loading branch information
bobbyiliev authored Aug 18, 2024
2 parents ec4c054 + 19ad412 commit aeb3ff3
Show file tree
Hide file tree
Showing 18 changed files with 3,007 additions and 321 deletions.
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ To download a copy of the ebook use one of the following links:
## 📘 Chapters

- [**About the book**](ebook/en/content/000-introduction.md)
- [**Introduction to Docker**](ebook/en/content/001-docker.md)
- [**Installing Docker**](ebook/en/content/002-installation.md)
- [**Working with Docker containers**](ebook/en/content/003-docker-containers.md)
- [**What are Docker Images**](ebook/en/content/004-docker-images.md)
- [**What is a Dockerfile**](ebook/en/content/005-dockerfile.md)
- [**Docker Network**](ebook/en/content/006-docker-networking.md)
- [**What is Docker Swarm mode**](ebook/en/content/007-docker-swarm.md)
- [**Managing the cluster**](ebook/en/content/007-docker-swarm.md)
- [**Chapter 1: Introduction to Docker**](ebook/en/content/001-docker.md)
- [**Chapter 2: Installing Docker**](ebook/en/content/002-installation.md)
- [**Chapter 3: Working with Docker Containers**](ebook/en/content/003-docker-containers.md)
- [**Chapter 4: What are Docker Images**](ebook/en/content/004-docker-images.md)
- [**Chapter 5: What is a Dockerfile**](ebook/en/content/005-dockerfile.md)
- [**Chapter 6: Docker Networking**](ebook/en/content/006-docker-networking.md)
- [**Chapter 7: Docker Volumes**](ebook/en/content/007-docker-volumes.md)
- [**Chapter 8: Docker Compose**](ebook/en/content/008-docker-compose.md)
- [**Chapter 9: Docker Security Best Practices**](ebook/en/content/009-docker-security.md)
- [**Chapter 10: Docker in Production: Orchestration with Kubernetes**](ebook/en/content/010-docker-and-kubernetes.md)
- [**Chapter 11: Docker Performance Optimization**](ebook/en/content/011-docker-performance.md)
- [**Chapter 12: Docker Troubleshooting and Debugging**](ebook/en/content/012-docker-debugging.md)
- [**Chapter 13: Advanced Docker Concepts and Features**](ebook/en/content/013-docker-tips.md)
- [**Chapter 14: Docker in CI/CD Pipelines**](ebook/en/content/014-docker-ci-cd.md)
- [**Chapter 15: Docker and Microservices Architecture**](ebook/en/content/015-docker-microservices.md)
- [**Chapter 16: Docker for Data Science and Machine Learning**](ebook/en/content/016-docker-ml.md)
- [**Conclusion**](ebook/en/content/999-conclusion.md)

## 🌟 Sponsors
Expand Down Expand Up @@ -91,18 +99,6 @@ We will utilize the ["Deploy to DigitalOcean" Button](https://www.digitalocean.c

Coming soon

## 💻 Interactive training

You can follow the interactive training online here:

[Interactive Docker training](https://docker.bobby.sh/training.html)

The training was built with Katacoda. You can find the Katacoda repository [here](https://github.com/bobbyiliev/katacoda).

For more information on how to use Katacoda make sure to follow the steps from this tutorial here:

[How to Use Katacoda to Create Highly Engaging Training Tutorials](https://devdojo.com/bobbyiliev/how-to-use-katacoda-to-create-highly-engaging-training-tutorials)

## 👋 About the author

My name is Bobby Iliev, and I have been working as a Linux DevOps Engineer since 2014. I am an avid Linux lover and supporter of the open-source movement philosophy. I am always keen on doing what I cannot do in order to learn how to do it, and I believe in sharing knowledge.
Expand Down Expand Up @@ -130,7 +126,7 @@ If you ever need to create a graphic, poster, invitation, logo, presentation –
## 🔗 Links

- [My blog](https://bobbyiliev.com)
- [Free $100 Credit For DigitalOcean](https://m.do.co/c/2a9bba940f39)
- [Free $200 Credit For DigitalOcean](https://m.do.co/c/2a9bba940f39)
- [Join DevDojo](https://devdojo.com?ref=bobbyiliev)
- [Ibis](https://github.com/themsaid/ibis/)
- [Canva](https://www.canva.com/)
Expand All @@ -148,5 +144,3 @@ If you ever need to create a graphic, poster, invitation, logo, presentation –
## 🤲 Contributing

If you are contributing 🍿 please read the [contributing file](CONTRIBUTING.md) before submitting your pull requests.


115 changes: 81 additions & 34 deletions ebook/en/content/001-docker.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,106 @@
# Introduction to Docker
# Chapter 1: Introduction to Docker

It is more likely than not that **Docker** and containers are going to be part of your IT career in one way or another.
## What is Docker?

After reading this eBook, you will have a good understanding of the following:
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.

* What is Docker
* What are containers
* What are Docker Images
* What is Docker Hub
* How to installing Docker
* How to work with Docker containers
* How to work with Docker images
* What is a Dockerfile
* How to deploy a Dockerized app
* Docker networking
* What is Docker Swarm
* How to deploy and manage a Docker Swarm Cluster
### Key Concepts:

I'll be using **DigitalOcean** for all of the demos, so I would strongly encourage you to create a **DigitalOcean** account to follow along. You would learn more by doing!
1. **Containerization**: A lightweight form of virtualization that packages applications and their dependencies together.
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.

To make things even better you can use my referral link to get a free $100 credit that you could use to deploy your virtual machines and test the guide yourself on a few **DigitalOcean servers**:
## Why Use Docker?

**[DigitalOcean $100 Free Credit](https://m.do.co/c/2a9bba940f39)**
Docker offers numerous advantages for developers and operations teams:

Once you have your account here's how to deploy your first Droplet/server:
1. **Consistency**: Ensures applications run the same way in development, testing, and production environments.
2. **Isolation**: Containers are isolated from each other and the host system, improving security and reducing conflicts.
3. **Portability**: Containers can run on any system that supports Docker, regardless of the underlying infrastructure.
4. **Efficiency**: Containers share the host system's OS kernel, making them more lightweight than traditional virtual machines.
5. **Scalability**: Easy to scale applications horizontally by running multiple containers.
6. **Version Control**: Docker images can be versioned, allowing for easy rollbacks and updates.

[https://www.digitalocean.com/docs/droplets/how-to/create/](https://www.digitalocean.com/docs/droplets/how-to/create/)
## Docker Architecture

I'll be using **Ubuntu 21.04** so I would recommend that you stick to the same so you could follow along.
Docker uses a client-server architecture:

However you can run Docker on almost any operating system including Linux, Windows, Mac, BSD and etc.
1. **Docker Client**: The primary way users interact with Docker 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).

Here's a simplified diagram of the Docker architecture:

## What is a container?
```
┌─────────────┐ ┌─────────────────────────────────────┐
│ Docker CLI │ │ Docker Host │
│ (docker) │◄───►│ ┌────────────┐ ┌───────────┐ │
└─────────────┘ │ │ Docker │ │ Containers│ │
│ │ Daemon │◄────►│ and │ │
│ │ (dockerd) │ │ Images │ │
│ └────────────┘ └───────────┘ │
└─────────────────────────────────────┘
┌─────────────────────┐
│ Docker Registry │
│ (Docker Hub) │
└─────────────────────┘
```

According to the official definition from the [docker.com](docker.com) website, 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. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.
## Containers vs. Virtual Machines

Container images become containers at runtime and in the case of Docker containers - images become containers when they run on Docker Engine. Available for both Linux and Windows-based applications, containerized software will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.
While both containers and virtual machines (VMs) are used for isolating applications, they differ in several key aspects:

![](https://github.com/bobbyiliev/introduction-to-docker-ebook/raw/main/ebook/en/assets/images/infrastructure.png)
| Aspect | Containers | Virtual Machines |
|-----------------|---------------------------------------|-------------------------------------|
| OS | Share host OS kernel | Run full OS and kernel |
| Resource Usage | Lightweight, minimal overhead | Higher resource usage |
| Boot Time | Seconds | Minutes |
| Isolation | Process-level isolation | Full isolation |
| Portability | Highly portable across different OSes | Less portable, OS-dependent |
| Performance | Near-native performance | Slight performance overhead |
| Storage | Typically smaller (MBs) | Larger (GBs) |

## What is a Docker image?
## Basic Docker Workflow

A **Docker Image** is just a template used to build a running Docker Container, similar to the ISO files and Virtual Machines. The containers are essentially the running instance of an image. Images are used to share containerized applications. Collections of images are stored in registries like [DockerHub](https://hub.docker.com/) or private registries.
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.

![](https://github.com/bobbyiliev/introduction-to-docker-ebook/raw/main/ebook/en/assets/images/process.png)
Here's a simple example of this workflow:

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

## What is Docker Hub?
# Ship the image to Docker Hub
docker push username/myapp:v1

DockerHub is the default **Docker image registry** where we can store our **Docker images**. You can think of it as GitHub for Git projects.
# Run the container
docker run -d -p 8080:80 username/myapp:v1
```

Here's a link to the Docker Hub:
## Docker Components

[https://hub.docker.com](https://hub.docker.com)
1. **Dockerfile**: A text file containing instructions to build a Docker image.
2. **Docker Compose**: A tool for defining and running multi-container Docker applications.
3. **Docker Swarm**: Docker's native clustering and orchestration solution.
4. **Docker Network**: Facilitates communication between Docker containers.
5. **Docker Volume**: Provides persistent storage for container data.

You can sign up for a free account. That way you could push your Docker images from your local machine to DockerHub.
## 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.

## Conclusion

Docker has revolutionized how applications are developed, shipped, and run. By providing a standardized way to package and deploy applications, Docker addresses many of the challenges faced in modern software development and operations. As we progress through this book, we'll dive deeper into each aspect of Docker, providing you with the knowledge and skills to leverage this powerful technology effectively.
Loading

0 comments on commit aeb3ff3

Please sign in to comment.