Earthly "WITH DOCKER" (DinD) failed in CI
WITH DOCKER starts a nested Docker daemon inside the build so RUN can call docker. That inner daemon needs privileges and resources. When they are missing, the daemon fails to start and the WITH DOCKER block errors.
What this error means
A WITH DOCKER block fails with "failed to start dockerd" or "Cannot connect to the Docker daemon" inside the target, or times out waiting for the inner daemon.
+integration | WITH DOCKER --load app:latest=+image
+integration | timed out waiting for docker daemon to start
Error: solve: failed to solve: WITH DOCKER: dockerd did not become readyCommon causes
The inner Docker daemon lacks privileges
Docker-in-Docker needs elevated privileges. If buildkitd itself is not privileged, the nested dockerd cannot start.
Not enough resources for two daemons
Running dockerd inside buildkitd is memory and disk heavy; a small runner can starve the inner daemon.
How to fix it
Run buildkitd privileged
- Ensure the buildkitd container runs privileged so nested dockerd can start.
- Give the runner enough memory and disk for two daemons.
- Load images into WITH DOCKER via --load or --pull explicitly.
WITH DOCKER --load app:latest=+image
RUN docker run --rm app:latest ./run-tests.sh
ENDGive the daemon time and space
Use a larger runner and let the inner daemon initialize before RUN calls docker.
How to prevent it
- Run buildkitd privileged when using WITH DOCKER.
- Size runners for two concurrent daemons.
- Load only the images the block needs.