Prevent Mac sleep during a Docker build
A large Docker image build can run for many minutes of sustained CPU work, and a Mac that sleeps partway through cancels it. Here is how to prevent Mac sleep during a Docker build and let battery and thermal limits decide when to stop instead.
Why sleep cancels a build
A docker build runs in the background while you do other things, which is exactly the situation where an idle timer or a closed lid triggers sleep.
When the Mac sleeps, the build does not pause politely and resume, it gets cut off. You come back to an incomplete image, and depending on where it stopped you lose the layer cache you were waiting on and rebuild from further back than you would like.
On a multi-stage build with a slow dependency install or a big compile step, that can mean throwing away ten or twenty minutes of work to a power setting.
Staying awake and watching the heat
LidRun detects Docker activity and holds the Mac awake while a build runs, so it can complete without an idle or lid-close sleep interrupting it.
Builds are heavy. Compiling and packing layers pins the CPU, and on a laptop that means real heat, especially with the lid closed. LidRun reads thermal state continuously through the build and gates the session on it, so a long compile does not run unwatched.
If thermal pressure climbs past your limit or charge drops too low, LidRun lets the Mac sleep rather than pushing the hardware to keep building. That is the trade it makes on purpose: finishing a build is good, but not at any cost to the machine.
When you need it
This is for the long ones: a from-scratch image, a CI-style full rebuild locally, a base image you are iterating on that takes real time. Those are the builds that outlast an idle timer and the ones worth protecting.
A quick rebuild with a warm cache finishes in seconds and never gets near sleep, so you do not need any of this for day-to-day iteration.
If you have watched a long build die to a lid close more than once, it is worth trying LidRun and letting it hold the Mac awake, plugged in, with thermal watch on.
Tips for heavy builds
Plug in for big builds. Sustained CPU load drains a laptop fast, and mains power keeps the focus on heat rather than charge.
Keep the Mac on a hard, ventilated surface so the heat from a long compile has somewhere to go, particularly with the lid shut.
Set a cooling profile and a session timer, so a build that hangs or loops does not keep the Mac awake and warm far longer than you intended.
LidRun keeps your work running with the lid closed, with battery and thermal safety built in.
Frequently asked
Yes, while battery and thermal state stay within your thresholds. If a limit is reached, LidRun lets the Mac sleep instead of pushing through.
LidRun watches thermal state continuously and cooling profiles respond as the workload heats up, within what the hardware allows, which helps reduce risk on long builds.
If a safety threshold ends the session, the build stops like any interrupted build. Keeping it plugged in and cool is the way to let it run to completion and keep the cache.
Yes, with keep-running mode on, as long as conditions stay within your limits. A hard, ventilated surface and mains power are strongly recommended for lid-closed builds.