<none> 存储库和标签是什么?为什么在我使用 docker 构建时会出现它们?
What are <none> repository and tags? Why do they appear when I use docker build?
这是 docker images
在我 运行 docker build
之前显示的内容。
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest a38da0bd9e0b 6 seconds ago 523.8 MB
golang onbuild b4997c557048 10 days ago 517.2 MB
在我对 myapp
源代码进行一些更改后,我 运行 docker build -t myapp .
最终得到了名为 <none>
.
的图像
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest a38da0bd9e0b Less than a second ago ago 523.8 MB
<none> <none> e4209f97e819 10 minutes ago 523.8 MB
golang onbuild b4997c557048 10 days ago 517.2 MB
我知道我可以使用 docker rmi <IMAGE ID>
删除它们,但为什么首先会发生这种情况?我怎样才能防止这种情况发生?我正在构建的 Dockerfile
看起来像这样。
FROM golang:onbuild
EXPOSE 8080
如果您将标签或图片名称重新分配给另一张图片,您的图片将丢失其标签或名称。真的就这么简单。您的 myapp
标记为 latest
且 ID 为 a38da0bd9e0b
的回购图像曾经在图像 ID e4209f97e819
.
上命名和标记
您没有在构建命令中正确设置标签。尝试:
docker build -t repo/stuff:tag .
如果您的 Dockerfile 名为“Dockerfile”并且您位于要构建的目录中,这将起作用。
当您 运行 docker image list
时,它会显示 repo/stuff
作为存储库,tag
作为 TAG
这是 docker images
在我 运行 docker build
之前显示的内容。
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest a38da0bd9e0b 6 seconds ago 523.8 MB
golang onbuild b4997c557048 10 days ago 517.2 MB
在我对 myapp
源代码进行一些更改后,我 运行 docker build -t myapp .
最终得到了名为 <none>
.
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest a38da0bd9e0b Less than a second ago ago 523.8 MB
<none> <none> e4209f97e819 10 minutes ago 523.8 MB
golang onbuild b4997c557048 10 days ago 517.2 MB
我知道我可以使用 docker rmi <IMAGE ID>
删除它们,但为什么首先会发生这种情况?我怎样才能防止这种情况发生?我正在构建的 Dockerfile
看起来像这样。
FROM golang:onbuild
EXPOSE 8080
如果您将标签或图片名称重新分配给另一张图片,您的图片将丢失其标签或名称。真的就这么简单。您的 myapp
标记为 latest
且 ID 为 a38da0bd9e0b
的回购图像曾经在图像 ID e4209f97e819
.
您没有在构建命令中正确设置标签。尝试:
docker build -t repo/stuff:tag .
如果您的 Dockerfile 名为“Dockerfile”并且您位于要构建的目录中,这将起作用。
当您 运行 docker image list
时,它会显示 repo/stuff
作为存储库,tag
作为 TAG