Report this

What is the reason for this report?

How many containers should I run in one DO droplet?

Posted on March 20, 2015

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?



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!

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.

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

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.