Skip to content
Latchkey

AWS CDK "Cannot connect to the Docker daemon" during asset bundling in CI

CDK bundles certain assets (NodejsFunction, PythonFunction, Docker image assets) by running a container. The bundling step invokes docker and the daemon is not running or not reachable on the runner, so bundling fails.

What this error means

cdk synth or deploy fails during "Bundling asset ..." with "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" or "docker: command not found".

cdk
Bundling asset MyAppStack/MyFunction/Code/Stage...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Error: docker exited with status 1

Common causes

No Docker daemon on the runner

The asset uses Docker-based bundling but the runner has no Docker available, or the daemon is stopped.

esbuild missing forces a Docker fallback

NodejsFunction prefers local esbuild and only falls back to Docker when esbuild is absent; without either, bundling fails.

How to fix it

Provide local bundling tools to skip Docker

  1. Install esbuild so NodejsFunction bundles locally without Docker.
  2. For PythonFunction, ensure the toolchain is present so local bundling is used.
  3. Re-run; CDK no longer needs a container.
Terminal
npm install --save-dev esbuild

Ensure Docker is running on the runner

On runners that do support Docker, confirm the daemon is up before synth.

Terminal
docker info  # must succeed before cdk synth

How to prevent it

  • Install esbuild for NodejsFunction so bundling stays local.
  • Use a runner with Docker only when an asset genuinely requires it.
  • Pin bundling tooling so behaviour is reproducible.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →