Catalogue
Error: Docker is unreachable. Docker needs to be running to build inside a container.

Error: Docker is unreachable. Docker needs to be running to build inside a container.

🌐 日本語で読む

When I ran a build with sam build --use-container, the following error occurred.

1
Error: Docker is unreachable. Docker needs to be running to build inside a container.

Specifying DOCKER_HOST

Check the current context.

1
2
3
$ docker info | grep 'Context:'

Context: desktop-linux

Check the endpoint.

1
2
3
$ docker context ls | grep desktop-linux

desktop-linux * moby Docker Desktop unix:///Users/kenzo.tanaka/.docker/run/docker.sock

By specifying DOCKER_HOST and running the command again, I was able to avoid the error.

1
2
3
$ env SAM_CLI_TELEMETRY=0 \
DOCKER_HOST=unix:///Users/kenzo.tanaka/.docker/run/docker.sock \
sam build --use-container --cached --parallel

That’s all.
For your reference.

Error: Docker is unreachable. Docker needs to be running to build inside a container.

https://kenzo0107.github.io/en/2024/08/27/docker-is-unreachable/

Author

Kenzo Tanaka

Posted on

2024-08-27

Licensed under