Configuring Docker VM Default Memory Limits


Docker for mac allows me to set the default, system-wide memory limit for a container. It doesn’t seem like NixOS does, and my container has silently been running out of memory lately. Is the default unlimited? If not, how do I configure it?

I’m using docker-compose but not swarm.

Does the Docker distribution for Nix use a VM?

1 Like

No, Docker on NixOS (and more generally on Linux) doesn’t use a VM as the container APIs that Docker uses (namespaces and cgroups) are native on Linux.

To limit the resources you can use the --ulimit option on docker run commands or the --default-ulimit (man dockerd) option of the daemon. Use option virtualisation.docker.extraOptions to add it and see ulimit --help and . Remember that using the latter option the limits are set per container, not globally