假设我有一个git repo,其中包含来自其他git repo的新文件和docker文件(以及其他文件).
我想将此仓库克隆到我自己的本地计算机上,然后我要用Docker构建该仓库.所以我会执行@H_404_3@
@H_404_3@
docker build -t name:v1 cloned-folder/
但是,在那之后,当我键入docker images时,我得到了两个图像:name:v1和来自仓库的图像.@H_404_3@
最佳答案
如果您的Dockerfile以“ FROM< image>”开头,则Docker映像将始终同时显示< image> (基本图像),名称:v1.@H_404_3@
在git repo中管理Dockerfile的事实并不重要.@H_404_3@
@H_404_3@
git clone URL_to_my_repo
and this repo contains repo mentioned earlier with my extra own files.
Thendocker build -q -t mynewimage:v1 cloned_folder/
.
after that I get two images when I typedocker images
@H_404_3@
- image from the
FROM
section of Dockerfile and
mynewimage:v1
.
What I want is to have only one image:mynewimage:v1
.
这是可以预期的(可以看到2张图像):您的第二张图像是根据第一张图像的层构建的:为了使mynewimage能够正常工作,您需要同时使用两者(因为union filesystem).