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".
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 1Common 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
- Install esbuild so NodejsFunction bundles locally without Docker.
- For PythonFunction, ensure the toolchain is present so local bundling is used.
- Re-run; CDK no longer needs a container.
npm install --save-dev esbuildEnsure Docker is running on the runner
On runners that do support Docker, confirm the daemon is up before synth.
docker info # must succeed before cdk synthHow 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.