I am trying to set resources limits in my docker-compose.yml file.
Here it is:
version: "3.7"
services:
postgres:
build: "docker/postgres"
container_name: "postgres"
ports:
- 5432:5432
environment:
POSTGRES_USER: prodev
POSTGRES_PASSWORD: prodev
POSTGRES_MULTIPLE_DATABASES: pro_dev, pro_test
networks:
- my_proto_app
the_api:
deploy:
resources:
limits:
cpus: '0.001'
memory: 50M
reservations:
cpus: '0.0001'
memory: 20M
image: the_api:latest
ports:
- 8080:8080
depends_on:
- postgres
links:
- postgres
networks:
- my_proto_app
networks:
my_proto_app:
internal: false
However, when I run docker stats in order to gain insight into my resources limits, I notice that my limits are not taken into account:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
c0b7d2fffc42 postgres 0.04% 20.89MiB / 1.952GiB 1.05% 148kB / 171kB 0B / 856kB 16
0a0f9e482f86 api_the_api_1 2.16% 739.5MiB / 1.952GiB 37.00% 409kB / 464kB 0B / 73.7kB 59
Can someone please help ?
edit: I run the app with the following command: docker-compose up