当我使用 docker-compose 文件下载映像时,图像是重复的。 这是我的码头工人-compose.yml
版本:"3" 服务业: 乌班图: 构建: ./Linux container_name:乌班图 stdin_open:真 tty: true
My Dockerfile in linux folder
来自 ubuntu
命令"$docker images"的输出:
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest ccc7a11d65b1 9 days ago 120 MB
ubuntu_ubuntu latest ccc7a11d65b1 9 days ago 120 MB
为什么这种口是心非?
在你的 Dockefile 中,你使用了FROM ubuntu
,所以你只是继承了图像,没有做任何事情。因此,新图像只不过与ubuntu
图像相同。这就是为什么您看到相同的id
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest ccc7a11d65b1 9 days ago 120 MB
ubuntu_ubuntu latest ccc7a11d65b1 9 days ago 120 MB
这并不意味着您240MB
占用了相同的两个图像。这只是意味着ubuntu
和ubuntu_ubuntu
指向同一图像,并且图像大小120 MB
。
你可以做以下事情
docker tag ubuntu ubuntu_my
它将创建另一个具有该名称以及相同 ID 和大小的条目。名称和标记只是对 ID 的引用。多个名称可以指向同一 ID。