编程辅导 Containerization and Docker

Containerization and Docker

Outlines Containerization
• Limitations of Virtual Machines

Copyright By PowCoder代写 加微信 powcoder

• Virtual Machines vs Containers
• Container orchestration tools
Introduction to Docker
• Containers • Images
• Dockerfile
• Docker Registry • Networking
• Building an image
• Running a container
• Docker compose and Docker SWARM mode

Containerization

Virtualization vs Containerization
• T h e many advantages of virtualization, such as application containment and horizontal scalability, come at a cost: resources. The guest OS and binaries can give rise to duplications between VMs wasting server processors, memory and disk space and limiting the number of VMs each server can support.
• Containerization allows virtual instances to share a single host OS (and associated drivers, binaries, libraries) to reduce these wasted resources since each container only holds the application and related binaries. The rest are shared among the containers.

Virtualization vs Containerization
Virtualization Overhead
Shared Bins / Libs

Virtualization vs Containerization
Virtual Machines Containers
Run on virtual HW, have Share same OS kernel their own OS kernels
Communication
Through Ethernet devices IPC mechanisms (pipes, sockets)
Depends on the Hypervisor Requires close scrutiny
Performance
Small overhead incurs Near native performance
when instructions are
translated from guest to
File systems and libraries File systems can be shared, are not shared between and libraries are
guest and host OS
Startup time
Slow (minutes) Fast (a few seconds)
Large size Small size (most is re-use)

In the Real World, VMs and Containers can/do Co-exist
When deploying applications on the cloud, the base computation unit is a Virtual Machine. Usually Docker containers are deployed on top of VMs.

Are Containers Better than VMs?
It depends …
• The size of the task on hand
• The life span of the application • Security concerns
• Host operation system
Containers vs Virtual Machines: Which is a better fit for you?
Containers vs Virtual Machines: How to tell which is the right choice for your enterprise?

What is a Container?
• Similar concept of resource isolation and allocation as a virtual machine.
• Without bundling the entire hardware environment and full OS.

What container runtimes are in use?
• Container technologies: Docker, containerd, cri-o, rkt, LxD …
• Docker is currently the leading software container platform

What are Container Orchestration Tools?
Container orchestration technologies provides a framework for integrating and managing containers at scale
• Networking
• Service discovery and load balancing
• Health check and self-healing
• Security
• Rolling updates
• Simplify container management processes
• Help to manage availability and scaling of containers

Container Orchestration Tools
• Kubernetes and Hosted Kubernetes:
• Docker SWARM / Docker Compose
§ OpenShift
§ Amazon Elastic Container Service (ECS) § Apache Mesos

Introduction to Docker
“Leads the pack with a robust container platform well-suited for the enterprise”
The Forrester Enterprise Container Platform, Q4 2018 Report

• Docker is by far the most successful containerization technology.
• Over 3.5 million applications have been placed in Docker containers and over 37 billion containerized applications have been downloaded (March 2018, according to Docker).
• It uses resource isolation features of the Linux kernel to allow independent “containers” to run within a single Linux instance.
• Docker can also be installed on Mac and Windows computers. It it is deeply integrated with the macOS Hypervisor framework and Microsoft Hyper-V virtualization or LCOW.

• Microsoft have announced native support for Docker.
• Native Windows apps can now be built, shipped and run in Docker containers that work on both Windows Server 2016 and Windows 10 Enterprise.
• Docker versions:
• Docker CE (Community Edition, free)
• Docker EE (Enterprise Edition, $$$, USD$750 – USD$3500+
per node per year)

Install Docker
• How to install Docker:
• Get Docker CE for Linux (Ubuntu)
Share Linux kernel
No more VirtualBox, but LinuxKit VM on macOS,
• Get Docker CE for Mac
• Get Docker CE for Windows LinuxKit VM / LCOW on Windows
• Get Docker Compose
Linux Container on Windows: https://docs.microsoft.com/en- us/virtualization/windowscontainers/deploy-containers/linux- containers

A Bit of Docker Nomenclature
• Container: a process that behaves like an independent machine, it is
a runtime instance of a docker image.
• Image: a blueprint for a container.
• Dockerfile: the recipe to create an image.
• Registry: a hosted service containing repositories of images. E.g.,
the Docker Hub (https://hub.docker.com)
• Repository: is a sets of Docker images.
• Tag: a label applied to a Docker image in a repository.
• Docker Compose: Compose is a tool for defining and running multi-containers Docker applications.
• Docker SWARM: a standalone native clustering / orchestration tool for Docker.

Manage Data in Docker
• By default, data inside a Docker container won’t be persisted when a container is no longer exist.
• You can copy data in and out of a container.
• Docker has two options for containers to store files on the host machine, so that the files are persisted even after the container stops.
• Dockervolumes(ManagedbyDocker,/var/lib/docker/volume/) • Bindmounts(Managedbyuser,anywhereonthefilesystem)

Networking
Docker has different networking options:
• “host”: every container uses the host network stack; which means all containers share the same IP address, hence ports cannot be shared across containers (Linux only, not for macOS or Windows)
Nginx container running on “host” network on an Ubuntu Server

Networking
Nginx container running on “host” network on macOS
Nginx container running on “host” network on Windows

Networking
• “bridge”: containers can re-use the same port, as they have different IP addresses, and expose a port of their own that belongs to the hosts, allowing the containers to be somewhat visible from the outside.
Read more: https://docs.docker.com/network/

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com