How many containers should I run in one DO droplet?

Currently, I’m running 5 applications in Docker containers in one 10GB droplet. These usually run fine when they’ve all been deployed. There apps get very little traffic, so it doesn’t make sense to give them that much space when only a couple of people a day visit them.

The problem is that, sometimes, when I deploy one of my applications my droplet goes to 100% CPU usages or I get a ‘Cannot allocate memory’ error. Every time I deploy an app I’m basically building the image and the running the container (fig build and fig up).

Am I doing something wrong? I do I just actually need a new droplet?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

There isn’t really an upper limit on the number of Docker containers that can be run on a single host beyond whatever resources the processes need. In some larger deployments, people will run hundreds of containers on the same host. If you haven’t yet done so, the first thing I’d recommend is adding a SWAP file to the server. It will give you a little more leeway regarding memory usage. Check out this tutorial for all the details:

If it’s just the building of the image that’s leading to the memory errors, then that might do it.

If the applications in the containers are what’s using up the resources, then you might want to constrain them. Docker allows you to restrict the amount of memory and cpu that is available for each container. This great blog post gets into the specifics. The fig documentation notes that you can specify a mem_limit in your fig.yml file.

Awesome response! Thanks Andrew. I’ll take a look at these.