Book Image

Mastering Docker - Third Edition

By : Russ McKendrick, Scott Gallagher
Book Image

Mastering Docker - Third Edition

By: Russ McKendrick, Scott Gallagher

Overview of this book

Docker has been a game-changer when it comes to how modern applications are deployed and created. It has now grown into a key driver of innovation beyond system administration, with an impact on the world of web development. But how can you make sure you're keeping up with the innovations it's driving, or be sure you're using it to its full potential? Mastering Docker shows you how; this book not only demonstrates how to use Docker more effectively, but also helps you rethink and reimagine what's possible with it. You will cover concepts such as building, managing, and storing images, along with best practices to make you confident, before delving more into Docker security. You'll find everything related to extending and integrating Docker in new and innovative ways. Docker Compose, Docker Swarm, and Kubernetes will help you take control of your containers in an efficient manner. By the end of the book, you will have a broad, yet detailed, sense of what's possible with Docker, and how seamlessly it fits in with a range of other platforms and tools.
Table of Contents (17 chapters)

The differences between dedicated hosts, virtual machines, and Docker

So, we know what problems Docker was developed to solve. We now need to discuss what exactly Docker is and what it does.

Docker is a container management system that helps us easily manage Linux Containers (LXC) in an easier and universal fashion. This lets you create images in virtual environments on your laptop and run commands against them. The actions you perform to the containers, running in these environments locally on your machine, will be the same commands or operations that you run against them when they are running in your production environment.

This helps us in that you don't have to do things differently when you go from a development environment, such as the one on your local machine, to a production environment on your server. Now, let's take a look at the differences between Docker containers and typical virtual machine environments.

The following diagram demonstrates the difference between a dedicated, bare-metal server and a server running virtual machines:

As you can see, for a dedicated machine we have three applications, all sharing the same orange software stack. Running virtual machines allow us to run three applications, running two completely different software stacks. The following diagram shows the same orange and green applications running in containers using Docker:

This diagram gives us a lot of insight into the biggest key benefit of Docker, that is, there is no need for a complete operating system every time we need to bring up a new container, which cuts down on the overall size of containers. Since almost all the versions of Linux use the standard kernel models, Docker relies on using the host operating system's Linux kernel for the operating system it was built upon, such as Red Hat, CentOS, and Ubuntu.

For this reason, you can have almost any Linux operating system as your host operating system and be able to layer other Linux-based operating systems on top of the host. Well, that is, your applications are led to believe that a full operating system is actually installed—but in reality, we only install the binaries, such as a package manager and, for example, Apache/PHP and the libraries required to get just enough of an operating system for your applications to run.

For example, in the earlier diagram, we could have Red Hat running for the orange application, and Debian running for the green application, but there would never be a need to actually install Red Hat or Debian on the host. Thus, another benefit of Docker is the size of images when they are created. They are built without the largest piece: the kernel or the operating system. This makes them incredibly small, compact, and easy to ship.