Robert Christ
Robert Christ

Reputation: 2210

"naming to docker.io", explanation and prevention?

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.

Upvotes: 92

Views: 32050

Answers (1)

swysocki
swysocki

Reputation: 1076

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)

Upvotes: 69

Related Questions