Increase memory of Docker container with docker-compose on Windows? Increase memory of Docker container with docker-compose on Windows? docker docker

Increase memory of Docker container with docker-compose on Windows?


In docker compose version 2.* you could use the mem_limit option as below

version: '2.4'services:  my-svc:    image: microsoft/mssql-server-windows-developer    mem_limit: 4G

In docker compose version 3 it is replaced by the resources options which requires docker swarm.

version: '3'services:  my-svc:    image: microsoft/mssql-server-windows-developer    deploy:      resources:        limits:          memory: 4G

There is a compatibility flag that can be used to translate the deploy section to equivalent version 2 parameters when running docker-compose --compatibility up. However this is not recommended for production deployments

From documentation

docker-compose 1.20.0 introduces a new --compatibility flag designed to help developers transition to version 3 more easily. When enabled, docker-compose reads the deploy section of each service’s definition and attempts to translate it into the equivalent version 2 parameter. Currently, the following deploy keys are translated:

  • resources
  • limits and memory reservations
  • replicas
  • restart_policy

condition and max_attempts All other keys are ignored and produce a warning if present. You can review the configuration that will be used to deploy by using the --compatibility flag with the config command.

We recommend against using --compatibility mode in production. Because the resulting configuration is only an approximate using non-Swarm mode properties, it may produce unexpected results.


Looking for options to set resources on non swarm mode containers?

The options described here are specific to the deploy key and swarm mode. If you want to set resource constraints on non swarm deployments, use Compose file format version 2 CPU, memory, and other resource options. If you have further questions, refer to the discussion on the GitHub issue docker/compose/4513.

You can use the docker-compose file on version 2 instead of version 3. You can use mem_limit (available on version 2) to set the memory limit. So you can use a docker-compose file like this:

version: "2.4"services:  sql-server:    image: microsoft/mssql-server-windows-developer    environment:      - ACCEPT_EULA=Y      - SA_PASSWORD=t3st&Pa55word    mem_limit: 4GB

You can check the memory limit using docker stats.


Was also out for setting this up via docker-compose. Had a hard time figuring out why sql server worked on a new machine but not any longer on my older one. Finally recalled I had tuned the size down able to allocate in Docker Desktop. Utilizing this you find it through the settings button, Resources/Advanced. Setting Memory to 2GB resolved the issue for me.