Docker 1 - Docker Introduction
Introduction
The process of developing, deploying, and managing software applications can be complex.
Development & Deployment Process:
- Teams involved: Development team (creates software) and Operations team (deploys and manages infrastructure).
- Example: Building an order-tracking portal used across company outlets.
- Stages: Development, QA (Quality Assurance), Pre-production, and Production environments.
Key Challenges:
Managing Hosting Environments:
- Need for consistent software and hardware management across different environments.
- Configuration of network access, data storage, and security must be consistent and reproducible.
Continuity in Software Delivery:
- Consistent deployments are crucial.
- Each deployment package should include everything needed for the application to function (e.g., packages, binaries, libraries).
- Dependencies must match in terms of software versions and architecture.
Efficient Hardware Use:
- Applications should run in isolation from others on the same hardware.
- Aim to run multiple applications per server without interference, maximizing resource use.
Application Portability:
- Portability is essential for scenarios like scaling or infrastructure failure.
- The ability to redeploy software quickly to a new environment with minimal downtime, even if the infrastructure differs.
Next Steps:
- Before diving into Docker features that address these challenges, there will be a brief overview of Docker concepts and architecture.
What is Docker?
- Docker is a containerization platform used to develop, ship, and run containers.
- Docker doesn’t use a
hypervisor
, and you can run Docker on your desktop or laptop if you’re developing and testing applications. - The desktop version of Docker supports Linux, Windows, and macOS.
- For production systems, Docker is available for server environments, including many variants of Linux and Microsoft Windows Server 2016 and above.
- Many clouds, including Azure, support Docker.
What is a container?
- A container is a loosely isolated environment that allows us to build and run software packages.
- These software packages include the code and all dependencies to run applications quickly and reliably on any computing environment.
- We call these packages
container images
. - The container image becomes the unit we use to distribute our applications.
What is software containerization?
- Software containerization is an OS-virtualization method used to deploy and run containers without using a virtual machine (VM).
- Containers can run on physical hardware, in the cloud, on VMs, and across multiple operating systems.
Docker Architecture
- The Docker platform consists of several components that we use to build, run, and manage our containerized applications.
Docker Engine
The Docker Engine is a client-server application with the following components:
- Docker Daemon: A background service that runs on the host system. The Docker Daemon manages Docker objects, such as images, containers, networks, and volumes.
- REST API: An interface that specifies how the Docker Daemon can interact with it.
- Docker CLI (Docker Client): A command-line interface that allows users to interact with the Docker Daemon.
- Docker Compose (Docker Server): A tool for defining and running multi-container Docker applications.
The client communicates with the server using a REST API, which enables the client to also communicate with a remote server instance.
Docker Client:
- Two options:
- Command-line interface (CLI) called
docker
. - Graphical User Interface (GUI) called
Docker Desktop
.
- Command-line interface (CLI) called
- Both interact with a Docker server using the Docker REST API to manage containers (local or remote).
Docker Server:
- A daemon named
dockerd
. - Handles client requests via the Docker REST API.
- Manages the lifecycle of containers and can interact with other Docker daemons.
Docker Objects:
- Objects include networks, storage volumes, plugins, and other service items.
- These objects are created and configured to support container deployments.
Docker Hub:
- A SaaS-based Docker container registry.
- Default public registry for storing and distributing container images.
- Alternative options:
- Private Docker registry.
- Cloud provider options include Azure Container Registry for storing images for Azure services.
How Docker images work
Docker Images Overview:
- A container image is the unit used to distribute applications in Docker.
- The container format is standardized for both developers and operations teams.
Software Packaged in a Container:
- Includes more than just the application code.
- Comprises application code, system packages, binaries, libraries, configuration files, and the OS running in the container.
- Example: A .NET Core MVC app deployed using nginx on Ubuntu Linux, all packaged into a single container image.
What is a Container Image?
- A container image is a portable package containing all the software needed to run an application.
- When executed, a container image becomes a container (the in-memory instance).
- Immutability: Once built, a container image cannot be changed. To make changes, a new image must be created.
- This immutability ensures that the image used in production is identical to the one used in development and QA.
What is the host OS?
- The host OS is the operating system on which the Docker Engine is installed.
- Docker containers running on Linux share the host OS kernel, and don’t require a container OS as long as the binary can access the OS kernel directly.
- However, Windows containers need a container OS.
- The container depends on the OS kernel to manage services such as the file system, network management, process scheduling, and memory management.
What is the container OS?
- The container OS is the operating system that runs inside the container.
- We have the flexibility to include different versions of Linux or Windows operating systems in a container.
- This flexibility allows us to access specific OS features or install additional software our applications might use.
- The container OS is isolated from the host OS, and it’s the environment in which we deploy and run our application.
- Combined with the image’s immutability, this isolation means the environment for our application running in development is the same as in production.
- In our example, we’re using Ubuntu Linux as the container OS, and this OS doesn’t change from development or production.
- The image we use is always the same.
What is the Stackable Unification File System (UnionFS)?
Unionfs (Stackable Unification File System):
- Used to create Docker images by stacking directories (branches) so they appear merged, though physically separate.
- Allows adding/removing branches while building the file system.
Layering in Docker Images:
- Example: Building an image for a web app by layering Ubuntu as the base image, then adding nginx and the web app on top.
- When a container runs, a final writable layer is created, which doesn’t persist after the container is destroyed.
Base Image:
- An image that uses the Docker
scratch
image (an empty image with no filesystem layer). - Assumes the application can directly use the host OS kernel.
- An image that uses the Docker
Parent Image:
- A container image used as a starting point to create new images.
- Example: Using an Ubuntu-based image that already has nginx installed to create a new image.
- Typically includes a container OS.
Difference Between Base and Parent Images:
- Base Image: Offers more control over the final image contents; starts from scratch.
- Parent Image: Builds on an existing image, usually with some OS or application components already included.
- Note: On Windows, container images must be based on Windows base container images, provided and serviced by Microsoft.
This post is licensed under CC BY 4.0 by the author.