Piotr Gołofit
Posted on March 2, 2022
If you are reading this post, you probably already heard about Docker. You may be wondering, why is Docker so popular? Is it just another hype word, or is it really useful? Will it bring you any value in the long term? Or will be gone in the next few years like many other fancy tools? And finally, should your development team start using Docker?
In this article, I will show you a few good reasons to use Docker, and a couple of examples where it may not be the best option. But let’s start by clarifying, what Docker actually is?
What is Docker?
In a nutshell, Docker is a tool that allows developers to bundle all the ingredients of software they create into unified boxes - called Docker containers. Key ingredient is usually the code, but most apps or websites won’t work without a database, configuration files, runtime libraries or other third-party software. Putting these together in a box makes it easier to launch the app on another developer's computer or the server. And because Docker containers are unified and independent from the outside world, the software built with them will work in a consistent, predictable way on each machine.
If you want to understand it better, make sure to check my previous blog post on What is Docker?. Knowing the basics, let’s see when you should consider using Docker in your project, and when not.
Good reasons to use Docker
From my experience, you should consider using Docker in your project if:
1. Your development team is not set in stone
How often do your development team change? Introducing new developers to the project always takes some time. Before they can start coding they have to set up their local development environment for the project - eg. some local server, database, or third party libraries. This may take from a few hours to many days, depending on the project complexity and how well is the project setup manual. Docker automates this setup & installation work so new developers can be productive from the first day. Instead of doing everything manually, they simply run one command that will prepare the development environment for them. This saves a lot of time, and the bigger is your development team and higher rotation, the more you will gain by using Docker.
2. Your software runs in different environments
I assume your software runs in at least two different environments - developers computer, and some server. Even in such a simple case, you can notice inconsistent behavior of your app between the machines it runs on. Something that worked on a developer's computer may not work on the server. And the number of issues grows with every new environment - like another server (test server vs production server) or simply another developer’s computer with a different operating system. Docker allows you to run the software in containers separated from the outside world, so your app can work in a consistent, predictable way in every environment.
3. Your software grows and consists of many bits and pieces
Developers add new libraries, services, and other dependencies to the software daily. The more complex becomes your software the harder it is to keep track on all its parts that are required for it to run. Without Docker, all the changes in the project setup have to be communicated to other developers and documented. Otherwise, their version of the code will stop working, and they won’t know why. With Docker, all the required components of the software are specified in Docker configuration files (like Dockerfile and docker-compose.yml). And if something is specified to this configuration it is automatically added for every developer working on the project.
4. You want your software to be scalable and handle more users
Want to scale your application to new markets or branches? Great! But will it handle the growing number of users? Docker won’t automatically make your app scalable but can help with this. Docker containers can be launched in many copies that may run in parallel. So the more users you have, the more containers you launch (eg. in the cloud). Before you do so, your software has to be prepared for running multiple instances at the same time. But if the scalability blockers are already removed, Docker containers will come in very handy to launch a scalable application.
5. Your hosting infrastructure may change in the future and you don’t want to be locked
Small websites and applications don’t require complex hosting infrastructure. But when a business grows and evolves, so do the server requirements. In the fast-paced business environment, web infrastructure needs to be flexible enough to adapt quickly. Both to ensure that your website won’t crash and that the costs of the infrastructure correspond to the actual needs. And because Docker containers are unified and very well adopted, they can be launched in almost any server environment. So when your needs change, your software can be placed somewhere else. So you won’t be locked by any hosting vendor or a specific type of infrastructure.
6. You do some proof of concepts and test new technologies for your software
Docker is quite useful if you want to experiment with different technologies. Want to adopt some new database, programming language, or other tools? Most probably there is already a Docker template for this (called Docker Image) created by a docker community. Docker Hub is a large repository of ready docker images for almost any technology you want to use. Just find the image you want and add it to your Docker configuration. No need for time-consuming installation or debugging compatibility issues.
If at least some of the above statements are true for your projects, you should probably give Docker a try. It can be useful for the majority of web development projects, but there are also some cases when it will not bring a lot of value. Let’s see some of them.
When to avoid Docker?
None of the below cases (except maybe the last one) automatically make Docker useless for your project. But if you hit any of these, you should rethink if Docker will be the best solution for your software development. Better think twice before adopting Docker if:
1. Your software product is a desktop application
Docker is very useful for web applications running on a server or console-based software. But if your product is a standard desktop application, especially with a rich GUI, Docker may not be the best choice. Although it is technically possible to build such an app with Docker, it isn’t the natural environment for running software with a graphical interface and it requires additional workarounds.
2. Your project is relatively small and simple
Docker is really handy if your software consists of multiple parts. It makes it easier to install these and keep a track of all the dependencies. But it does not come like this out of the box. Someone has to prepare the initial project setup for Docker (Dockerfiles, docker-compose.yml, entry points, etc.) and maintain it in the future. So if your app is relatively simple and does not require any additional tools or services, you may start without Docker. It can be added later on when your software grows.
3. Your development team consists of one developer
If your development team is simply a one-man-army, the benefits of Docker will be smaller. Docker helps to ensure that all the developers have access to all the necessary bits and pieces of the software they work on. So if someone adds software dependencies, everyone has them when needed. If it is just one developer, there is no such need. But even in this case, Docker may help, eg. if that person resigns and someone has to take over the project. But that can be handled with proper documentation instead. Docker simply automates this, but the fewer people in the team, the smaller the need for automation.
4. You are looking for a solution to speed up your application
Docker may speed up your development process significantly, but not necessarily your app itself. Although it helps with making your application scalable, so more users will be able to use it, the single instance of your app will usually be just a hint slower than without Docker. Fortunately, Docker containers are smaller than for example Virtual Machines and require much fewer resources. In most cases, the performance overhead of Docker won’t be visible for you, but if your goal is to boost the speed of your app, Docker itself is not the solution for that.
5. Your development team consist mostly of MacBook users
Speaking of speed, Docker has serious performance issues when running on macOS. These are related to how volumes are mounted, and the underlying osxfs filesystem. In short, if your app performs a lot of read/write disk operations (and almost every app does some) it may be very, very slow on Mac. So if your development team consists of Apple fans, Docker may not be the best solution. Fortunately, there are a few things that MacBook users can do to improve their experience with Docker. Our developer Krzysiek summarized them in his recent post - Docker on Mac - how to speed it up?.
6. Your team don’t know how to use Docker properly
Last, and maybe most important case when you should not use Docker. Docker can work like charm and significantly speed up the development process. But as well may become your nightmare, if it is not used properly. Very large Docker images that start up for many minutes. Difficult to debug issues that do not produce any useful logs. Security issues when using random, third-party Docker images. Developers that install dependencies on their machine and not in the Docker images. Docker configuration mixed with additional manual commands to be executed. These all can cause a lot of frustration, issues and in the end, may cost real money. So if your development team doesn't know how to use Docker properly, don’t use it just because everyone does.
So should my team use Docker?
Well, in most cases, yes. Docker, when used properly, can be beneficial quite quickly. And will work for most of the software products. Containerization, in general, is the natural next step in the software development industry and won’t disappear anytime soon. Docker may be replaced by other tools or next versions of Docker, but the general concept will remain. But as with every tool, Docker won’t help you if it is not used properly. So before your development team starts to complain about Docker, let them read our free ebook Docker Deep Dive - they will thank you later.
Posted on March 2, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 20, 2024
November 19, 2024