"naming to docker.io", explanation and prevention?
Asked Answered
K

1

80

Naming to docker.io/library/imageName

When I build an image from a dockerfile, I see this statement appear in the docker build log, as the last statement of the build log that prints in the console.

What does this mean? Does this mean a copy of the image has been pushed to docker.io?

If so, is there any way to prevent this? It seems to continue happening even if I run docker logout.

If it matters, I am currently using a fresh install of docker for windows with wsl2 integration, and am running the docker build command within ubuntu linux.

Kimsey answered 26/2, 2021 at 23:15 Comment(1)
Can you add more context in the output around this message? (Lines before, lines after, the build command you use)Ymir
B
61

docker.io/library is the default registry applied when you don't specify a registry URL.

When you specify -t in the build command, the text before the / is considered the registry URL.

Here is an example of building an image, one without a specific registry and one with:

# no registry specified
➜  docker build . -t my-image
[+] Building 0.5s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 86B                                                                                                                                                                                                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                                                                                                                                                        0.0s
 => CACHED [1/2] FROM docker.io/library/ubuntu:20.04                                                                                                                                                                                                                                                                                                                   0.0s
 => [2/2] RUN cat /etc/lsb-release                                                                                                                                                                                                                                                                                                                                     0.4s
 => exporting to image                                                                                                                                                                                                                                                                                                                                                 0.0s
 => => exporting layers                                                                                                                                                                                                                                                                                                                                                0.0s
 => => writing image sha256:4a97ceefb5314bdf91886a28142c9b0b33c992c94b1847d5ae1b38723b2279e3                                                                                                                                                                                                                                                                           0.0s
 => => naming to docker.io/library/my-image                                                                                                                                                                                                                                                                                                                0.0s

# registry set to "my.docker.registry"
➜ docker build . -t my.docker.registry/my-image
[+] Building 0.1s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 36B                                                                                                                                                                                                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                                                                                                                                                        0.0s
 => [1/2] FROM docker.io/library/ubuntu:20.04                                                                                                                                                                                                                                                                                                                          0.0s
 => CACHED [2/2] RUN cat /etc/lsb-release                                                                                                                                                                                                                                                                                                                              0.0s
 => exporting to image                                                                                                                                                                                                                                                                                                                                                 0.0s
 => => exporting layers                                                                                                                                                                                                                                                                                                                                                0.0s
 => => writing image sha256:4a97ceefb5314bdf91886a28142c9b0b33c992c94b1847d5ae1b38723b2279e3                                                                                                                                                                                                                                                                           0.0s
 => => naming to my.docker.registry/my-image

The image tag specifies where the image will be uploaded if you do a docker image push <image name>.

In the first case, if you did docker image push my-image it would push to docker.io/library.

In the second case, if you did docker image push my.docker.registry/my-image it would push to a registry at the URL my.docker.registry (assuming it exists)

Bowker answered 11/3, 2021 at 16:40 Comment(4)
so assuming I don't push, nothing actually goes to the registry? It is just giving me a notification message that if I push, that is the registry it will go to? @BowkerKimsey
Correct. It is just stored locally unless you run "docker image push <tag>"Bowker
and can you actually push to a different registry to override to default?Thirtyone
@Thirtyone in order to that you have to rename the image tag using docker tag <current_image_name> <new_image_name>, so for example: docker tag docker.io/library/my-image my.docker.registry/my-imageHimalayas

© 2022 - 2024 — McMap. All rights reserved.