Limit Useable Host Resources in Docker Compose Without Swarm

Limit resources in docker-compose v3

I was wondering the same thing and found this:
https://github.com/docker/compose/issues/4513

So in short it's just not possible to do that, you have to use the version 2.1 of the docker-compose format to be able to specify limits that are not ignored by docker-compose up

Limit container resources on Ubuntu

Compose file version 2 supports these in the per-service specification.

version: '2.4'
services:
queue:
cpu_count: 2
mem_limit: 4g
memswap_limit: 4g # -1 doesn't seem to be valid

In general version 2 has more of the docker run options, and version 3 is geared more towards Swarm-specific options. The version 3 equivalent would be the deploy: resources: section, but everything under deploy: is ignored by docker-compose up. Both versions are supported and it's fine to use version 2 Compose files if you need it.



Related Topics



Leave a reply



Submit