Is Docker Compose good for production? The two opposing developers’ camps have been trying to determine whether it is so for a long time. We at Optimum Web attempted to integrate the experience of our experts and that of our industry colleagues into comprehensive research designed to answer this question.

 

What is Docker Compose?

Docker Compose is a tool that was developed to assist in defining and sharing multi-container applications. 

Compose allows you to use a YAML file to define and configure your application’s services. After that, you can create and start all the services from your configuration with a single command. 

Here’s how the process of using Docker Compose usually looks like: 

  • First, you define the environment of your app with a Dockerfile. Thus you can further reproduce it in any place.
  • Second, you specify the services that create your app in docker-compose.yml. This way, you get the possibility to run them together in an isolated environment. 
  • Third, start docker compose up. After that, the Docker compose command will be able to run your entire app.

Docker is an open-source software platform, helping you build apps based on containers, thus making it easier for developers to package their software. They represent tiny and light execution environments that use the same operating system kernel but run separately. 

 

Can Docker Compose be used in production?

Docker Compose can be used in production. The question is whether it should be at all. 

Docker Compose in production | Pros

First of all, you need to define the meaning of “production” for yourself. 

What Docker Compose does is just applying a single command to orchestrate (start and stop) multiple containers. Nothing you couldn’t do with ordinary docker commands. So, if you mean a single server by saying “production,” where all the instances and relationships are defined, you can easily use Docker Compose. 

We have to acknowledge that not every app needs to scale horizontally. Your software can process up to millions of requests per month on a single kernel, with Docker Compose facilitating the process. However, one shouldn’t forget that this simplicity doesn’t come for free. 

You can’t rely on load balancers, and every deploy is accompanied by downtime. It is short, but it can be critical in case your app has multiple users.

On the other hand, if the “production” implies multiple docker hosts and dynamic extension across the cluster, we recommend Kubernetes, Swarm or another alternative.

Docker Compose in production | Cons

According to the most influential people in the Docker community, such as Bret Fisher, Docker Compose is not the best solution to be used in production. Check their points below: 

  • You have to waste time and effort by manually installing/updating docker-compose on your server. The Linux package managers (apt, yum) can not help you with this.
  • You have to start from scratch when it comes to high availability.  
  • You don’t have health checks available in production with Docker Compose. Unfortunately, docker run and docker-compose won’t re-create containers that failed a built-in health check.
  • You can’t replace a container without downtime. No rolling updates are available.
  • You don’t have access to the yum/apt packages. Docker Compose requires pip install or manual updates. 
  • Docker Compose fails to prove itself on reboots. In fact, it is only a wrapper around the Docker API. This means that you can not count on it running as a separate process. This way, all the YAML changes (including containers) are erased from Docker’s memory once it restarts.

 

Develop with Docker | The best way to use Docker Compose for development

 

What is Docker in software development?

The role of Docker in modern software development is hard to be overestimated. It enables developers to package applications into containers. Thus the application source code is combined with OS (operating system) libraries and dependencies required to run that code in any environment.

You had to buy a server, install Linux, and set up a LAMP stack to run a web app in earlier times. You could then set up a second server to balance the load once your application gained popularity and, respectively, more traffic.

These days everything looks different. A single server is no longer in focus. It is substituted by the cloud, which represents arrays of software-based inter-dependent and redundant servers (containers). Thus a ‘server cloud’ notion went from hardware to software.

Why use Docker containers in development?

  1. Small size
  2. Agility
  3. High speed
  4. Potential to save on both labour and infrastructure overheads
  5. Smooth raise of environments for both automated and manual app testing.

The best proof of their importance is the fact that the world’s largest search engine company relies on them permanently. Isn’t this the best testament to a developer tool?

 

Is Docker good for local development?

When used in local development, Docker can surprise you. Despite a more complicated setup, the possibility of slow testing, and the cost of installing new packages, some points make it good for local development. 

The benefits of Docker Compose for local development

  • No need to install or maintain the software on your local host machine  
  • Simplified collaboration of developers on a project due to the possibility to check the entire local development environment into source control.
  • A single command (docker-compose up) for the entire local development environment spin up.


A better dev workflow with Docker Compose

Introducing Compose into your development workflow can be very useful. It lets you benefit from the perks of Docker while forgetting about the complexity of your stack. Maybe you are familiar with running production images with Compose. Check some benefits of using it in development: 

  • Infrastructure as code

The image below is an example of a YML file taken from a basic to-do app. It builds (‘composes’) the API, DB, and web in an easy-to-read file. The Compose file here creates the web repository from its local Dockerfile, from which an API service is built in a remote Git repo.

a better dev workflow with docker compose

You can effortlessly modify the Compose file for your purposes while development lasts by starting a new branch. This happens because of treating each service as a separate container that you can orchestrate in any way you need. 

Other developers can also develop on the branch you created. For this, they need to pull the repo down and bring the new environment, tracked into source control, up. 

  • Portability

A single-command principle of Docker Compose enables you to pull down the web repo from GitHub and get the full stack app running in a second. All you have to do is use the docker-compose up and docker-compose down commands. 

More than that, your docker-compose.yml can be used all over the repository to create your own staging environments.

  • Testing

You can quickly run a test after test in an environment closely resembling your production one, thus shifting the load and risks from your local OS. Benefit from disposable and thus new and clean environments for each test.  

Of course, Compose has its speed bumps, and there are ways to remove them. However, this can negatively influence your Compose environments’ portability.

 

Compose is usually loved for ease of basic orchestration. It works perfectly fine on production when developing a simple, non-scalable app on a single host. However, any software that is expected to expand doesn’t imply using Docker Compose in production for its apparent restrictions.

See recommendations from the Docker team to make the most of Compose in production.

 

Docker Compose in Golang

Docker Compose in Python is not the only implementation existing. Some time ago, there was created a Go version of Compose. It was rewritten from Python to Golang, enabling developers to plug different backends like AWS ECS or Microsoft ACI. Now you can deploy to ECS and other clouds easier. 

Check this issue in the Docker Compose public roadmap for details and the compatibility notes for V2. 

Docker Compose definitely can make the work of a new developer easier. They just have to run a few commands to get a project started quickly and running on local environment. 

 

How to deploy with Docker Compose | Optimum web’s solution

In Optimum Web we get many inquiries from clients who want to integrate various open-source products into a single complex solution. People combine multiple applications or replace old ones with new ones. Some of them are thrown away because they are no longer supported. Approaches to solving business problems are changing. 

Usually, small companies choose free products and adjust them for their business purposes, combining some applications with others. Doing this right and making it work properly is what they typically need professional help for.

Moreover, not all open source web apps have a demo page to study it in more detail.

We discovered the possibility of finding the best product for a client startup easier than before and effectively combining applications from a single platform.

This is how a project called TryDirect appeared.

Try.Direct | Optimum Web’s Cloud Deployment

Try.Direct | Optimum Web's Cloud Deployment

TryDirect is a platform that helps a client to easily install and test a web application on their server in the cloud. We are now deploying to the major cloud platforms. Amazon EC2, Azure, Digital Ocean, Google Cloud, Hetzner Cloud, Linode, and Alibaba Cloud are just some of them.

TryDirect is a valuable solution for informational and/or research purposes, e.g., checking how a CRM or a CMS works.

Novice DevOps specialists can use this platform to smoothly deploy applications in the cloud using Docker Compose or save time and simplify their daily tasks. Docker Compose is great for prototyping business solutions. 

TryDirect is also helpful for developers. In our practice, there are often tasks for deploying LAMP or other stacks in various cloud services for a quick start of projects. Therefore, our collection includes Flask, Symfony, Laravel, Gin / Golang, and other starter templates.

Our client’s companies’ needs for constant IT infrastructure and software management are steadily growing. So we began working on a more advanced product for sophisticated users. It will allow working with Kubernetes clusters and do more than just various apps deployment. Our solution will enable the DevOps specialists to manage their project’s infrastructure, change it in the cloud, add and remove applications from the cluster.

 

Request a Consultation