DEV Community

Chris Wendt
Chris Wendt

Posted on

1

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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay