1
CHAPTER 1 | Introduction to Containers and Docker
CHAPTER
1
Introduction
to Containers
and Docker
Containerization is an approach to software development in which an application or service, its
dependencies, and its configuration (abstracted as deployment manifest files) are packaged together
as a container image. The containerized application can be tested as a unit and deployed as a
container image instance to the host operating system (OS).
Just as shipping containers allow goods to be transported by ship, train, or truck regardless of the
cargo inside, software containers act as a standard unit of software deployment that can contain
different code and dependencies. Containerizing software this way
enables developers and IT
professionals to deploy them across environments with little or no modification.
Containers also isolate applications from each other on a shared OS. Containerized applications run
on top of a container host that in turn runs on the OS (Linux or Windows). Containers therefore have a
significantly smaller footprint than virtual machine (VM) images.
Each container can run a whole web application or a service, as shown in Figure 2-1. In this example,
Docker host is a container host, and App1, App2, Svc 1, and Svc 2 are containerized applications or
services.
Figure 2-1. Multiple containers running on a container host
2
CHAPTER 1 | Introduction to Containers and Docker
Another benefit of containerization is scalability. You can scale out quickly by creating new containers
for short-term tasks. From an
application point of view, instantiating an image (creating a container) is
similar to instantiating a process like a service or a web app. For reliability, however, when you run
multiple instances of the same image across multiple host servers, you typically want each container
(image instance) to run in a different host server or VM in different fault domains.
In short, containers offer the benefits of isolation, portability, agility, scalability, and control across the
whole application lifecycle workflow. The most important benefit is the environment’s isolation
provided between Dev and Ops.
What is Docker?
Docker
is an
open-source project
for automating the deployment
of applications as portable, self-
sufficient containers that can run on the cloud or on-premises. Docker is also a
company
that
promotes and evolves this technology, working in collaboration with cloud, Linux, and Windows
vendors, including Microsoft.
Figure 2-2. Docker deploys containers at all layers of the hybrid cloud.
Docker containers
can run anywhere, on-premises in the customer datacenter, in an external service
provider or in the cloud, on Azure. Docker image containers can run natively on Linux and Windows.
However, Windows images can run only on Windows hosts and Linux images can run on Linux hosts
and Windows hosts (using a
Hyper-V Linux VM, so far), where host means a server or a VM.
Developers can use development environments on Windows, Linux, or macOS. On the development
computer, the developer runs a Docker host where Docker images are deployed, including the app
and its dependencies. Developers who work on Linux or on macOS use a Docker host that is Linux
based, and they can create images only for Linux containers. (Developers
working on macOS can edit
code or run the Docker CLI from macOS, but as of the time of this writing, containers don’t run
3
CHAPTER 1 | Introduction to Containers and Docker
directly on macOS.) Developers who work on Windows can create images for either Linux or Windows
Containers.
To host containers in development environments and provide additional developer tools, Docker
ships Docker Desktop for
Windows
or for
macOS
. These products install the necessary VM (the Docker
host) to host the containers.
To run
Windows Containers
, there are two types of runtimes:
•
Windows Server Containers provide application isolation through process and namespace
isolation technology. A Windows Server Container shares a kernel
with the container host and
with all containers running on the host.
•
Hyper-V Containers expand on the isolation provided by Windows Server Containers by running
each container in a highly optimized virtual machine. In this configuration, the kernel of the
container host isn’t shared with the Hyper
-V Containers, providing better isolation.
The images for these containers are created the same way and function the same. The difference is in
how the container is created from the image running a Hyper-V Container requires
an extra
parameter. For details, see
Hyper-V Containers
.
Dostları ilə paylaş: