Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
How to limit memory usage in docker-compose?

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%
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

deploy key only works in swarm mode and with docker-compose file version 3 and above.

In your case, use docker-compose file version 2 and define resource limits:

version: "2.2"

services:
  app:
    image: foo
    cpus: "0.5"
    mem_limit: 23m

See official docs here

over 4 years ago · Santiago Trujillo Denunciar

0

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

over 4 years ago · Santiago Trujillo Denunciar

0

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.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda