1

On macOS Monterey, the Docker process is using many GB of swap (virtual memory). So much swap, in fact, that my SSD filled up and caused file corruption. Here are some things I've done to try to limit the swap usage:

Running the container with --memory-swap limited:

docker run -dp <port stuff> -v <bind volume stuff> --cpus="2" -m 2g --memory-swap 6g --name <name> <image>

Limiting swap usage in Docker Desktop: Swap limited to 512 MB

Here's what continues to happen: After 24 hours (the swap usage increases throughout the day): Activity Monitor: Docker using 14.49 GB of VM and 14.51 GB total Memory; com.apple.Virtualization.VirtualMachine using 1.58 GB of VM and 2.00 GB of total Memory


Disk Utility: VM Partition using 19.33 GB The Docker process is the one using tons of swap, while the container (com.apple.Virtualizations.VirtualMachine) stays within its limits.

Restarting the container does not free up swap, while restarting the docker daemon does.

Is there anything I can do to prevent this abuse of swap? I don't want to disable swap entirely, but I'd like to keep Docker down to a few GB at most.

3
  • 2
    You appear to be using the experimental settings for Docker for Mac - Please disable those first to see if it corrects the issue.
    – Ezekiel
    Commented Aug 24, 2021 at 20:22
  • I'll try that and wait 24 hours.
    – tjcaul
    Commented Aug 24, 2021 at 20:32
  • 2
    You are using a beta OS and experimental features of Docker. Expect issues, especially like this. Report the issue to Docker
    – mmmmmm
    Commented Aug 24, 2021 at 20:41

1 Answer 1

1

Disabling Use the new Virtualization framework in Experimental Features seems to have solved the issue. I will submit a bug report to Docker.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .