Docker For Beginners
Docker, represented by a logo with a friendly looking whale, is an open source project that facilitates deployment of applications inside of software containers. Its basic functionality is enabled by resource isolation features of the Linux kernel, but it provides a user-friendly API on top of it. The first version was released in 2013, and it has since become extremely popular and is being widely used by many big players such as eBay, Spotify, Baidu, and more. In the last funding round, Docker has landed a huge $95 million, and it’s on track to become a staple of DevOps services.
How does it differ from Virtual Machines?
At a quick glance, virtual machines and Docker containers may seem alike. However, their main differences will become apparent when you take a look at the following diagram:
Apart from the hypervisor, virtual machine applications need a complete instance of the operating system and any supporting libraries. Containers, on the other hand, use the host’s operating system. In the sense that it manages the lifecycle of containers, Hypervisor is similar to the container engine (represented as Docker on the image). The only difference is that the processes running within the containers behave just like native processes on the host and do not incur any hypervisor-related overheads. Applications can also reuse the libraries and share data between containers.
Since the capabilities of both technologies are different, it is popular to see systems that combine virtual machines and containers. A good example is the Boot2Docker tool, which is defined in the Docker installation section.
Registries are located at the top of the architecture diagram. The Docker Hub, which hosts public and official images, is the default key registry. If desired, organizations will host their own private registries.
On the right-hand side we have images and containers. Images can be downloaded from registries explicitly (
docker pull imageName) or implicitly when starting a container. Once the image is downloaded it is cached locally.
Containers are picture instances — they are the living entity. Multiple containers based on the same picture may be running at the same time.
The Docker daemon is at the heart of the system, and it’s responsible for building, running, and controlling containers. It also manages the creation and storage of photographs. Finally, there is a Docker client on the left-hand side. It communicates with the daemon over HTTP. When on the same computer, Unix sockets are used, but remote control is possible through an HTTP-based API.
Docker runs natively on Linux, so depending on the target distribution it could be as easy as
sudo apt-get install docker.io. Refer to the documentation for details. Normally in Linux, you prepend the Docker commands with
sudo, but we will skip it in this article for clarity.
Docker cannot be run natively in Mac OS or Windows due to the Docker daemon’s use of Linux-specific kernel features. Instead, download and install the Boot2Docker program. A VirtualBox Virtual Machine, Docker, and the Boot2Docker management utilities make up the framework. You can follow the official installation instructions for MacOS and Windows to install Docker on these platforms.