Welcome back to Docker Bootcamp. We’ve learned a lot about how to use Docker in this series. In this post, we’ll look at when to use Docker. Docker is a great tool, but as with any technology, you should make sure it is the right tool for the job you are trying to accomplish.
Why Containers
-
Smaller and faster than VMs
Containers share the physical hardware resources with the host machine as well as pieces of the host operating system. There is no guest operating system sitting between the host and the application saving you space and increasing overall system performance.
-
Reproducibility
Containers are created from an image. Anywhere you distribute the image, the resulting container will behave in the same way.
-
Isolation
Containers are independent of one another. You can run multiple versions of the same software in separate containers without conflict. This is very helpful when one version requires an older version of a dependency since the dependencies are included in the image.
When to Use Containers
-
Learn a new tool
Containers are a great way to learn a new tool by playing in a disposable sandbox. When you run an application in a container, it is fully self-contained. The installation files are not spread out over the file system and the system registry. This makes it easy to fully remove the application. You can also use multiple versions of the same tool such as the new edge version or an old version simultaneously. This is difficult to do without containers because all versions of the same software tend to install to the same location on the file system.
-
Improve software delivery
Onboarding new developers is always a challenge. They must install and configure each piece of required software. If the installation instructions or a configuration is incorrect, it leads to wasted time comparing their environment to a working environment. With containers, everyone deploys the same image so everyone’s environment is the same and the software runs the same. This is true for each environment from development to production. The combination of software installed on any given host will not impact the software running in the container.
-
Improve software testability
Containers improve software testability by allowing you to run the same configuration as production on your local machine. The only difference will be the amount of physical hardware resources available on your local machine.
-
Fast scaling
Running your software in containers makes it fast and easy to scale your application. You can easily add more containers. You can manage your containers with orchestration tools such as Docker Swarm or Kubernetes.
-
Flexibility
Containers give your application a layer of flexibility. You can easily move to new hardware. You can configure automatic management to restart or recreate failed containers.
-
Reduce costs
You can run more containers on less hardware when compared to running your application in virtual machines. This is important in today’s cloud-based platform as a service time usage-based cost model.
-
Run a legacy application
Legacy applications typically depend on old versions of other software. Because all the dependencies are built into the image, you can run next to modern software without version conflicts.
-
Disaster recovery
Containers provide an easy way to roll back to a previous version of your application. Simply run your container and specify a previous version of the image to use.
When NOT to Use Containers
-
Your application is complicated
Even with tools such as Docker Swarm or Kubernetes, it can become difficult to manage a complicated application consisting of multiple containers, various degrees of interconnectivity, and multiple servers.
-
Performance is critical
Containers are faster than running your application in a virtual machine but slower than running in the native host OS.
-
Security is critical
Container security is a topic unto itself. Many images have default configurations or passwords. It is important to only download images from trusted sources. In the event a process is able to break out of a container, it has full access to the host running as the same user as the docker daemon. It can be easier to manage permissions and security in the host OS without the extra container layer.
-
You need to run on different operating systems
Images are built for one OS. An image built for windows cannot run on Linux because of how containers share the host OS.
-
You need to run an application with a GUI
Containers are primarily designed for console-based applications. You can run some Linux GUI applications by using X11 forwarding, but you will likely experience crashes and poor performance.
-
You do not have a container expert in-house
As with any technology you introduce into your business, you need someone that can support the technology. If you do not have such a person or a person that can learn the technology, troubleshooting can be a time-consuming and frustrating process.
-
You need to run on an old version of windows
Containers are only supported on Windows 10 (build 2004 and later) and Windows Server 2016 (and later). You can not run a Windows 8 container even in Windows 10.
Why Docker
-
Ease of use
Docker is the most popular and de facto way to manage containers on a local development environment. The command-line interface and desktop tools make using containers very simple.
-
Large community
Docker Hub contains many operating systems and applications that have already been containerized. This makes it fast and easy to pull an existing image and start your project.