Docker: ERROR [internal] load metadata for docker.io
Asked Answered
K

6

6

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.

Kerosene answered 22/9, 2022 at 9:56 Comment(0)
K
23

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
  }
}
Kerosene answered 22/9, 2022 at 9:56 Comment(3)
I have a similar error: ERROR [internal] load metadata for docker.io/library/ubuntu:latestWinch
Works but loses all the buildkit avantages.Nucleolar
NOTE: daemon config file at C:\Users\<USER>\.docker\daemon.jsonInterested
D
9

Solution
sudo rm ~/.docker/config.json
Rerun restart

Darton answered 18/1 at 7:36 Comment(2)
this gets the job done, things go back to normal with docker compose working again.Yeo
This works for me, running on MacBook Pro M3 MaxTipster
D
7

i encounter this problem when i build image at offline enviroment.

disable buildkit then it fixed.

 export DOCKER_BUILDKIT=0
Draconic answered 11/7, 2023 at 8:25 Comment(3)
Hey, your answer seems to be more a comment. You might want to adjust accordingly...Kerosene
@Kerosene Thank you for the reminder. I have already added the code.Draconic
Works for me thoughPhotomap
B
6

In Linux, the solution above didn't work for me but the following did:

docker pull <image-name>
Barayon answered 26/10, 2023 at 9:0 Comment(0)
T
0

docker pull [image-name] docker build [...]

On windows, I pulled the image first, then ran the build.

Tears answered 1/7, 2023 at 12:3 Comment(2)
If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From ReviewFiredog
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Barrows
B
0

This can sometimes happen if you have a momentary network blip. Sometimes the solution is just to run the Docker command again.

Bookbindery answered 29/5 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.