cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit and mem_swappiness are deprecated in version3.x
when using 3 version of docker-compose, we can use deploy
for non swarm mode or swarm mode, such as
version: "3.7"
services:
redis:
image: redis:alpine
container_name: testredis
deploy:
resources:
limits:
cpus: '0.50'
docker-compose --compatibility up
--compatibility is required (taken from the documentation): If set, Compose will attempt to convert deploy keys in v3 files to their non-Swarm equivalent