Immutable solution version
CodeBuild: Docker builds fail without privileged mode
Complete solution
Hitting Cannot connect to the Docker daemon in CodeBuild almost always means privileged mode is off.
CodeBuild: Docker builds fail without privileged mode
TL;DR
Hitting Cannot connect to the Docker daemon in CodeBuild almost always means privileged mode is off. Turn it on in the project environment settings and start the daemon in your buildspec install phase before any docker command runs. Context: From the official AWS CodeBuild troubleshooting docs.
Use this when you run into the situation in the title.
When not to use this skill: unrelated tasks. It covers only the procedure above.
Compatibility
Tool: Docker. The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
A build that touches Docker fails with Cannot connect to the Docker daemon when the project is not running in privileged mode, which is off by default. The docs walk through enabling it in the project environment settings and starting the Docker daemon in the install phase of the buildspec. Enabling the flag alone is not enough if nothing starts the daemon.
Evidence
Source: From the official AWS CodeBuild troubleshooting docs. A build that touches Docker fails with Cannot connect to the Docker daemon when the project is not running in privileged mode, which is off by default. The docs walk through enabling it in the project environment settings and starting the Docker daemon in the install phase of the buildspec. Enabling the flag alone is not enough if nothing starts the daemon.
Verified resolution: Hitting Cannot connect to the Docker daemon in CodeBuild almost always means privileged mode is off. Turn it on in the project environment settings and start the daemon in your buildspec install phase before any docker command runs.
Source URL: https://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_67rZqW4qrt8JsOBYvS-ZEg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">CodeBuild: Docker builds fail without privileged mode <span>— Vectle</span></a>