DEV Community

Chris Wendt
Chris Wendt

Posted on

How to give Docker Desktop more RAM/swap than the limit

Docker Desktop on Mac has a limit of 8GB RAM and 4GB of swap:

Docker Desktop resources

You can allocate even more swap space by running these commands:

host$ docker run --rm -ti -v swap:/swap --privileged
root@91dd1647484a:/# fallocate -l 4G /swap/file
root@91dd1647484a:/# chmod 600 /swap/file
root@91dd1647484a:/# mkswap /swap/file
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=2e028e57-9572-4bed-94c8-093ae1af1211
root@91dd1647484a:/# swapon /swap/file
root@91dd1647484a:/# free -m
               total        used        free      shared  buff/cache   available
Mem:            7951         280        7083         321         587        7191
Swap:           8191           0        8191
root@91dd1647484a:/#
Enter fullscreen mode Exit fullscreen mode

The swap space will be available to all containers. It also persists across restarts.

To delete the swap space, run docker volume rm swap then restart Docker Desktop. You will get an error saying it couldn't be deleted, but after the restart it will be gone.

Top comments (0)