Easily scale application with Docker Compose on Triton

Docker Compose is the easiest way to get started with dockerized, multi-container applications on Triton's Elastic Docker Host. The Triton Elastic Docker Host automatically runs your containers across the data center for the best performance and scale. Docker Compose makes it possible to start multi-container applications with a single command, docker-compose up -d, and quickly scale those applications with docker-compose scale.... It’s as if you can supercharge your application and become nimbler to the needs of your users.

With Docker Compose on Triton, you can manage the whole lifecycle of your application.

Watch the video

Watch the overview of how Docker Compose can make managing single or multi-service applications simple.

Video transcript

The best way to deploy an application powered by Docker on Triton is with Docker Compose.

Docker Compose makes it simple to run and update multi-container applications. All it takes is a simple configuration file, and with a short command you can get your application up and running, scale your application, and much more.

Let’s try it out with dockerized web application. This application only has one service, so the Docker Compose File will be very straight forward.

In your terminal, navigate to the directory of your application. Using the touch command to create an empty file, create the docker-compose.yml configuration.

Every service must first be declared. We’ll call this service nginx, as Nginx is the base image for this service.

Next, we’ll declare the service’s image. This will be the image you’ve already created for your application. It can also be one of the various official base images.

Then we’ll declare the ports. Because this is a web application, we know that we need to declare port 80.

We’ll declare a memory limit. We know this is a small application, so the container doesn’t need to have a limit any higher than 128 megabytes.

Finally, we’ll add a Triton CNS service label so that we can easily add a DNS name to our application. You can learn more about that in our video series on Triton CNS.

There are numerous other declarations that could be made, but for now, we’re ready to spin up our application.

Spinning up a container with Docker Compose is super simple. All it takes is this one command, docker compose up, and it will spin up a detached container named by the directory, service, and instance number.

Let’s get the DNS name of application, so we can open it in our browser. To do so, we’ll need to get some more information about the instance from Triton. The last result in our query will be our CNS-powered DNS name, which will remain unchanged no matter how big or small you scale the application.

That’s all it takes to spin up an app with Docker Compose! But say you want more containers up to handle larger volumes of traffic. You can scale it up just as easily. This will scale your application across the data center.

Let’s check out our application with dig to see how our DNS name is affected.

As you can see, there are now 3 IP addresses pointing to our DNS name, for the three existing containers.

In the browser, I can go back to the application and know it’s round-robinning through the existing containers in order to distribute the traffic.

A more complicated application may name 2, 3, 4, or more services in the Compose file. Check out the Docker Compose file for our WordPress application on the AutoPilot Pattern.

Spinning up WordPress is exactly the same process as deploying a single-service application. To scale, name the individual services and give a number of instances to create. You don't need to declare the same number of instances for each service.

Now go forth and spin up your applications quickly and easily with Docker Compose on Triton.



Post written by Alexandra White