upInCloud
upInCloud

Reputation: 1009

mem_limit not being honored with docker-compose?

I am trying to define a container in my docker-compose.yml file like so -

gitea:
  image: gitea/gitea:latest
  depends_on: 
    - mariadb
  env_file: 
    - gitea_env
  mem_limit: 100000000
  ports:
    - "127.0.0.1:4567:3000"
  volumes:
    - /var/lib/gitea:/data

However, once the container starts, I see with docker stats that the memory assigned to it is not limited to 100 MB. I am using version: '2' of docker-compose YML syntax and docker-compose version is 1.25.5.

Output of docker stats --all gitea shows -

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
dfed6585837c        gitea               0.25%               150MiB / 982.8MiB   15.27%              251kB / 102kB       57.2MB / 69.6kB     12

Docker version (docker --version) is - Docker version 19.03.8-ce, build afacb8b7f0

What is going wrong in my configuration?

Upvotes: 3

Views: 1567

Answers (1)

WSMathias9
WSMathias9

Reputation: 689

Make sure you are recreating the container after changing the memory limit:

docker-compose down && docker-compose up

Upvotes: 2

Related Questions