Here is part of my docker-compose.yaml file
version: '3.4'
services:
app:
build:
context: .
dockerfile: Dockerfile
working_dir: /app
deploy:
resources:
limits:
cpus: '0.50'
memory: 23M
Starting it docker-compose up -d
When I do docker stats it says that limit is still 1.9GiB. What am I doing wrong?
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM %
13b6588evc1e app_1 1.86% 20.45MiB / 1.952GiB 1.02%
Are you running the docker-compose in swarm mode ? If not Recommended to run 2.x version of compose file format.
3.X require docker-compose to be run in swarm mode for new set of resource directives to take effect.
Alternatives in 2.X are cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, mem_swappiness
If you not intend to use docker swarm stack deployments, always stick to the latest 2.x version supported by the docker engine version you operate. Docker versions 17.12 and later support compose file version 2.4. Docker-Compose has all features the cli provides, while swarm still lacks some of those: see https://github.com/moby/moby/issues/25303.
If you use docker-compose, all swarm related elements in a 3.x file will be ignorend, except secrets (or was it configs?!). If you start to mix 3.x only elements with 2.x only elements, your configuration will become invalid.