I found several posts and blogs on this but cannot get it to work as expected in my case.
I have a docker compose and I tried to add cpu limits per this blog. Tried:
version: "3"
services:
shell:
image: someaddress/executor-blah/main:latest
cpus: 4
entrypoint:
- /bin/bash
working_dir: /workspace
volumes:
- .:/workspace
However when I tried to run this container I got a compose error:
The Compose file './docker-compose.yaml' is invalid because: Unsupported config option for services.shell: 'cpus'
Tried also:
version: "3"
services:
shell:
image: someaddress/executor-blah/main:latest
cpus: 4
entrypoint:
- /bin/bash
working_dir: /workspace
volumes:
- .:/workspace
deploy:
resources:
limits:
cpus: '4'
This time the container composed but when I check on a async loop in my hosts terminal using top > 1
, all 8 of my laptops cores are used up by this process.
How can I limit a container to, in this case, 4 cores?