Search code examples
dockerdocker-desktopdocker-build

How to disable loading metadata while executing Docker build?


Windows 10, DockerDesktop v3.5.2, Docker v20.10.7

Whenever my computer is disconnected from the Internet
the command docker build -t my_image . produces output like the following.

Dockerfile contains line FROM some_public_image:123

 => [internal] load build definition from Dockerfile                             0.0s
 => => transferring dockerfile: 187B                                             0.0s
 => [internal] load .dockerignore                                                0.1s
 => => transferring context: 2B                                                  0.0s
 => ERROR [internal] load metadata for docker.io/library/some_public_image:123   0.0s
------
 > [internal] load metadata for docker.io/library/some_public_image:123:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition:
failed to do request: Head https://registry-1.docker.io/v2/library/some_public_image/manifests/123: 
dial tcp: lookup registry-1.docker.io on 192.168.65.5:53: no such host

Sometimes it causes build failure: not sure, but I guess when there were no network availability between the Docker daemon start and execution of docker build.

I suppose it tries to sync the pulled image with the repo version (i.e. check the image integrity), but would like to control this network activity and turn this "load metadata" off (saying I'm sure that all pulled images are fine) even when the connection is stable.

How to disable loading metadata while executing docker build command?


Solution

  • I have this problem too, and via Google I found other people asking about it with no good solution.

    My workaround:

    1. When I'm still on a good Internet connection I docker pull some_public_image:123.
    2. docker tag some_public_image:123 this_is_stupid_but_i_retagged_some_public_image.
    3. In my Dockerfile I use FROM this_is_stupid_but_i_retagged_some_public_image.

    I wouldn't merge this hack to main but it let me be productive on a long trip.