Skip to content
Latchkey

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.

earthly
+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 ready

Common 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

  1. Ensure the buildkitd container runs privileged so nested dockerd can start.
  2. Give the runner enough memory and disk for two daemons.
  3. Load images into WITH DOCKER via --load or --pull explicitly.
Earthfile
WITH DOCKER --load app:latest=+image
    RUN docker run --rm app:latest ./run-tests.sh
END

Give 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.

Frequently asked questions

What causes "Earthly "WITH DOCKER" failed"?
Docker-in-Docker needs elevated privileges. If buildkitd itself is not privileged, the nested dockerd cannot start.
How do I fix Earthly "WITH DOCKER" failed?
Run buildkitd privileged

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card