Introduction
A lightweight, stand-alone package that contains everything needed to run a piece of software, including the code, runtime, system tools, system libraries, and settings.
Last updated
A lightweight, stand-alone package that contains everything needed to run a piece of software, including the code, runtime, system tools, system libraries, and settings.
Last updated
Containerization is the process of encapsulating software code along with all of its dependencies inside a single package so that it can be run consistently anywhere.
Docker is an open source containerization platform. It provides the ability to run applications in an isolated environment known as a container.
Containers are like very lightweight virtual machines that can run directly on our host operating system's kernel without the need of a hypervisor. As a result we can run multiple containers simultaneously.
Each container contains an application along with all of its dependencies and is isolated from the other ones. Developers can exchange these containers as image(s) through a registry and can also deploy directly on servers.
A virtual machine is the emulated equivalent of a physical computer system with their virtual CPU, memory, storage, and operating system.
A program known as a hypervisor creates and runs virtual machines. The physical computer running a hypervisor is called the host system, while the virtual machines are called guest systems.
The hypervisor treats resources — like the CPU, memory, and storage — as a pool that can be easily reallocated between the existing guest virtual machines.
There are two types of hypervisors:
Type 1 Hypervisor (VMware vSphere, KVM, Microsoft Hyper-V).
Type 2 Hypervisor (Oracle VM VirtualBox, VMware Workstation Pro/VMware Fusion).
A container is an abstraction at the application layer that packages code and dependencies together.
Instead of virtualizing the entire physical machine, containers virtualize the host operating system only.
Containers sit on top of the physical machine and its operating system. Each container shares the host operating system kernel and, usually, the binaries and libraries, as well.
What's Different?
VMs
Containers
Size
Heavyweight (GB)
Lightweight(MB)
Boot Time
Startup time in minutes
Startup time in seconds
Performance
Limited performance
Native performance
OS
Each VM runs in its own OS
All containers share the host OS
Runs on
Hardware-level virtualization(Type1)
OS virtualization
Memory
Allocates required memory
Requires less memory space
Isolation
Fully isolated and hence more secure
Process-level isolation, possibly less secure
In a production environment that runs containers hosting critical applications, you would rather have your favorite admins install Docker Enterprise.
However, on your development machine or a continuous integration build machine, you can use the free Docker Engine Community or Docker Desktop depending on your machine type.
Use
Product
Developer machine
Docker Engine Community or Docker Desktop
Small server, small expectations
Docker Engine Community
Serious stuff/Critical applications
Docker Engine Enterprise or Kubernetes
Ubuntu Focal 20.04 (LTS)
Ubuntu Bionic 18.04 (LTS)
Ubuntu Xenial 16.04 (LTS)
Docker Engine is supported on x86_64
(or amd64
), armhf
, and arm64
architectures.
Older versions of Docker were called docker
, docker.io
, or docker-engine
.
It’s OK if apt-get
reports that none of these packages are installed.
Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.
Some users download the DEB package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.
In testing and development environments, some users choose to use automated convenience scripts to install Docker.
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
apt
package index and install packages to allow apt
to use a repository over HTTPS:Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
apt
package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:Remember to log out and back in for this to take effect!
To understand what just happened, you need to get familiar with the Docker Architecture, Images and Containers, and Registries.
A server which is a type of long-running program called a daemon process (the dockerd command).
A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
A command line interface (CLI) client.
Docker’s architecture is also client-server based. However, it’s a little more complicated than a virtual machine because of the features involved.
Docker Client: This is how you interact with your containers. Call it the user interface for Docker.
Docker Objects: These are your main components of Docker: your containers and images. We mentioned already that containers are the placeholders for your software, and can be read and written to. Container images are read-only, and used to create new containers.
Docker Daemon: A background process responsible for receiving commands and passing them to the containers via command line.
Docker Registry: Commonly known as Docker Hub, this is where your container images are stored and retrieved.
Docker objects are the docker images, containers, volumes, and networks.