Docker container vs Virtual machine 2018
Whenever we use some of Google functionality - Search, Gmail, Google Docs, whatever - we're issued a new container.
Docker is an open source application deployment container that evolved from the LinuX Containers (LXCs) used for the past decade. LXCs allow different applications to share operating system (OS) kernel, CPU, and RAM.
Docker allow us to run an application and its dependencies in resource-isolated processes.
"The VM model blends an application, a full guest OS, and disk emulation. In contrast, the container model uses just the application's dependencies and runs them directly on a host OS. Containers do not launch a separate OS for each application, but share the host kernel while maintaining the isolation of resources and processes where required".
"The fact that a container does not run its own OS instance reduces dramatically the overhead associated with starting and running instances. Startup time can typically be reduced from 30 seconds (or more) to one-tenth of a second. The number of containers running on a typical server can reach dozens or even hundreds. The same server, in contrast, might support 10 to 15 VMs".
"In Docker, applications and their dependencies, such as binaries and libraries, all become part of a base working image".
The isolation from OS kernel provided by containers is less robust than that of real virtual machines, which have independent kernels and run on top of a hypervisor. However, sharing the kernel allows containers to run faster and offers management features which are not easy with VMs.
The picture is from https://www.docker.com/whatisdocker/ - How is this different from Virtual Machines?.
Videos to watch:
- Docker Tutorial - What is Docker & Docker Containers, Images, etc?
- Introduction to Docker and Containers
Basically containers use a few new Linux kernel features:
- namespaces allows us to isolate processes from each other.
- cgroups allows us to limit resource utilization.
These features let us pretend we have something like a virtual machine, though it's not a virtual machine at all, but it's just processes running in the same Linux kernel.
Containers make our app shareable.
- All the needs of our app is defined in a text file (Dockerfile)
- A sample of Dockerfile - the following 4 lines construct the whole environment that's production ready:
FROM ubuntu:14:04 RUN apt-get install -y redis-server EXPOSE 6379 ENTRYPOINT ["/usr/bin/redis-server"]
- Containers contain everything our app needs:
- File system
- Containers use the following items from the host:
Type-1 bare-metal hypervisors
- VMware ESX/ESXi
- Microsoft Hyper-V
Type-2 hosted hypervisors
- VMware Workstation/Player
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization