October 2024
Nesrin Brahim
Docker Fundamentals
From: LearnKarts Coursera
“ The future depends on what you do Today”
– Pinterest
Contents
- Lesson 1: Introduction to Docker
- lesson 2: Docker Fundamentals
- Lesson 3: Getting Started with Docker
- Lesson 4: Build, manage, and distribute images.
- Lesson 5: Container Configuration.
- Lesson 6: Networking
- Lesson 7: Orchestration
- Lesson 8: Docker Container storage and volumes.
- Lesson 9: Docker Security
1
I. Introduction To Docker
1. Understand Docker ( video)
- Software development involves different teams (development, testing, operations)
working in various environments. Different environments cause code behavior
inconsistencies and issues. There are two solutions: virtualization and
containerization.
- Virtualization creates virtual machines (VMs) with separate CPU, memory, and
storage, using a hypervisor to segregate hardware resources — virtualization
components: host, guest, and virtualization layer. Virtual machines are isolated
systems running on a single server.
- Containerization packages code and dependencies for consistent application
execution across environments. Docker is a platform for containerization, enabling
faster development, shipping, and deployment of applications.
2. Differences between Docker and Virtualization ( video)
Virtualization Docker
- each VM has its OS. - Docker containers share the host OS.
→ VMs are heavy. → Lightweight (no hypervisor).
→ Slow to boot up. → Faster setup time.
→ better suited for long-term use. → Ideal for short activities.
→ Multiple VMs lead to un-stability. → Better Performance.
- requires some resources to be permanently - Containers use up only as many
allocated before the VM starts. resources as they need (small).
→ Wastage of resources. → Efficient use of resources.
→ Easy to scale up. → Easy to scale in and out.
→ Better option if one wants the full functionality → Better option to keep the number
operating system. of servers to a minimum.
2
- VMs are measured by gigabytes - Containers are measured by megabytes
→ Easy portability → Difficult to port the code across platforms
→ Data volumes cannot be shared → Data volumes can be shared.
3. DevOps & Docker ( video)
→ Devops: the release, configuring, and monitoring of software is in the hands of the person
developing it.
- development methodology
- aims to bridge the gap between development and operation.
- emphasizing communication, collaboration, and continuous integration.
→ Docker is a tool that eases continuous application deployment.
4. Containerization ( video)
- Containerization is the use of containers to deploy applications.
A container is a unit of software that
packages code and all its dependencies
→ to enable the application to run reliably and quickly
on other machines ( different computing environments).
3
+ isolation → security + Flexible
+ Scalability + Lightweight
+ loosely coupled + Portable
5. Why use docker ( video)
- Containerization vs. Virtualization: Unlike virtualization, which allows multiple OSs in a
host, Docker creates multiple containers for any type of application.
- Consistency and Efficiency: Docker eliminates the need for teams to install software
for testing, saving time and ensuring consistent environments across development and
deployment stages.
- Docker Hub: A repository where Docker images can be pushed
or pulled for use. Various communities contribute images, and
users can also create and upload their own.
6. Microservices (video)
- Microservices architecture: A variant of service-oriented architecture (SOA), dividing
applications into small, independent services.
- Monolithic vs Microservices: Microservices differ from traditional monolithic architectures
by breaking down software development into multiple segments handled by different
teams.
Microservices:
- support DevOps, bridging the gap between development and operations teams.
- allow for quick application updates with short production schedules, smaller release
cycles, and immediate feedback.
- Continuous monitoring tools measure the performance of microservices.
4
7. Advantages of Microservices (video)
- Cost-effective scalability: Microservices allow for easier and cheaper scaling.
- Fault isolation: If one microservice fails, others continue to function, limiting failure impact
- Granular scaling decisions: Resources can be allocated selectively to meet scaling
needs.
- Localized complexity: Each microservice functions as an independent, self-contained
application, making it easier to manage and debug.
- Business agility: Microservices enable faster experimentation, quicker failure recovery,
and increased developer productivity.
- Focused development teams: Teams can specialize in specific microservices, reducing
the complexity they need to understand.
- Business alignment: Microservices are structured around business capabilities, making it
easier to understand customer needs and adjust services without disrupting the whole
system.
8. Monolithic Vs. Microservices (reading)
Monolithic Architecture:
- The entire application is developed as a single unit with tightly coupled components.
- Containerization: The whole application is packaged in one Docker container.
- Deployment: Simple, single-container deployment.
- Scaling: Inefficient, as scaling replicates the entire application stack, even if only
some components need scaling.
- Maintenance: Requires redeploying the entire application for updates, which can be
time-consuming and risky.
Microservices Architecture:
- Application is decomposed into smaller, independent services focused on specific
business capabilities.
- Containerization: Each service is packaged in a separate Docker container.
- Deployment: Involves orchestrating multiple containers using tools like Docker
Swarm or Kubernetes.
- Scaling: Fine-grained, as individual services can be scaled independently, improving
resource efficiency.
- Maintenance: Updates to individual services are easier, reducing risk and downtime.
9. Docker Architecture (video)
Docker operates using a client-server model, its components include:
- Docker client - Docker daemon (Docker d)
- Docker host - storage modules, and Docker registry
- Network
5
- Docker Client: Communicates with the Docker daemon through API calls. It executes
Docker instructions via CLI or REST API.
- Docker Daemon: Manages container-related tasks such as building, running, and
managing Docker containers.
- Docker Host: The system where Docker containers and applications run, consisting
of the Docker daemon, images, containers, networks, and storage.
- Docker Images: Templates containing metadata to create containers. Images can be
reused or modified.
- Containers: Self-contained environments for running applications, encapsulating
resources, network, and storage configurations.
- Docker Registry: Repository for storing Docker images. Registries can be public
(e.g., Docker Hub) or private for organizational use.
Networking: Docker uses five main network drivers:
- Bridge (default)
- Host (no network isolation)
- Overlay (multiple Docker hosts)
- None (no network)
- Macvlan (assigns MAC addresses to containers)
Storage Options: Techniques for persistent storage include
- Data volumes: Stored outside containers using copy-on-write.
- Volume containers: Shared volumes between containers.
- Directory mounts: Mounting local directories from the host.
- Storage plugins: Link external storage to containers.
6
II. Docker Fundamentals
1. Docker Engine
Docker uses a client-server model where the client (CLI) sends commands to the server
(Docker daemon) via REST API, which executes and returns results.
Docker Components:
- Docker Daemon: The server that manages Docker objects (containers, images).
- REST API: Enables communication between the client and daemon.
- CLI: Command-line interface used to interact with Docker (Client).
Configuration: The Docker engine settings can be configured based on the requirements,
allowing automatic adjustment to changes using configuration management tools.
Platform Support: Docker engine can be installed on Linux, Windows, and macOS using
respective package formats (e.g., RPM for CentOS, EXE for Windows).
Plugins: provide extended functionality to the docker engine. Docker supports plugins like:
- Volume plugins: For persistent storage across multiple hosts.
- Network plugins: For network management.
- Plugins can be installed from public registries (Docker Hub) or created as custom
solutions.
an administrator handles the plugins’ lifecycle from installation to deletion.
Docker Swarm: A clustering and orchestration system for
managing multiple Docker hosts as a single swarm, enabling
scalable container deployment.
Data Volumes: Shared storage used across containers. They are easy to back up, portable
across Linux and Windows, and can be managed through CLI commands.
2. Components of Docker Engine
The components of the Docker Engine can be summarized as follows:
- Docker CLI: Acts as the client, where users enter commands.
- Docker Daemon: The server component that runs in the background, processes
commands, and manages Docker objects like containers, images, networks, and
volumes.
- Docker REST API: Facilitates communication between the CLI and the Docker
daemon, executing and transmitting commands and results.
7
Together, these components enable the creation, deployment, and management of
containerized applications. Containers are based on images, which can be pulled from public
registries like Docker Hub. Additionally, containers can be linked to networks and storage
volumes for complete application management.
3. Docker Communtiy Edition
Docker CE is the open-source version of Docker, available for free since its release in 2013.
It is suitable for both individual and commercial use. Docker CE can be downloaded from the
Docker store and is compatible with various operating systems.
Ideal for developers and small teams who want to experiment with containerized
applications.
4. Docker Enterprise Edition
Docker EE is designed for enterprises and IT teams that build, ship, and run business-critical
applications at scale. It provides more powerful features than the Community Edition (Docker
CE).
Features by Tier:
- Basic: Certified infrastructure and support.
- Standard: Advanced management features, user integration, and access control.
- Advanced: Security scanning and monitoring for vulnerabilities.
Docker EE is ideal for organizations requiring robust support, advanced features, and a
secure environment for deploying containerized applications.
5. Pricing for Docker
Docker CE: Free to use.
Features:
● Open-source and reusable.
● Shareable containers.
● Ideal for developers and small teams experimenting with Docker.
Docker EE
- Basic Tier: $1,500 per node per year (includes business-critical support).
- Standard Tier: $3,000 per node per year (includes business-critical support).
- Advanced Tier: $3,500 per node per year (includes business-critical support).
Trial: Free one-month trial available.
Features:
● Advanced capabilities for enterprise-level needs.
● Official support and maintenance.
● Security features and compliance.
8
6. Docker CE Vs. EE
Docker CE Docker EE