On Windows 10, Docker Desktop (Docker Engine v20.10.17, WSL enabled and running properly) fails to docker build
an image (that, btw, works properly on Debian 11) throwing following error:
docker build -t <image-name> .
[+] Building 2.3s (3/3) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2 0.0s
=> ERROR [internal] load metadata for docker.io/rocker/r-base:4.2.1 2.0s
------ > [internal] load metadata for docker.io/rocker/r-base:4.2.1: ------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to authorize:
rpc error: code = Unknown desc = failed to fetch anonymous token: Get
"https://auth.docker.io/token?scope=repository%3Arocker%2Fr-base%3Apull&service=registry.docker.io":
dial tcp: lookup auth.docker.io: no such host
A similar case was answered here, although the solution doesn't apply in my case. Searching the web yielded several similar (but not identical) cases with different solutions (including a reinstall), which all failed to solve this.
In the end I found a (or the) solution in the Docker forum:
in Docker Desktop, navigate to Settings > Docker Engine, change buildkit
to false
in the Docker daemon configuration file and then click "Apply & Restart".
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"features": {
"buildkit": false
}
}