By jorgesilva
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!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.