Many images created after build a docker im

2020-03-02 06:51发布

FROM scratch
MAINTAINER Aario <AarioAi@gmail.com>
ENV SHARED_GROUP docker

I build a docker image with above dockerfile. After runing docker build -t "aario/centos" . It creates this image aario/centos and the <none> image:

enter image description here

Is it ok? And how to solve it?

When I run docker rmi 2f??????? to remove the aario/centeros image. The <none> image will be removed on the same time.

2条回答
在下西门庆
2楼-- · 2020-03-02 07:12

Docker image is composed of layers:

docker history aario/centos

Each row you see using command above is a separate layer. Also, with time, some number of orphaned layers will fill up your disk space. You can safely remove them with:

docker image prune
查看更多
贪生不怕死
3楼-- · 2020-03-02 07:25

Those are intermediate image layers. I.e, all of the steps of your Dockerfile.

You can check what these images are made of with inspect command:

docker image inspect 2f???????

They do not use additional disk space, since they are part of your named image. They can save space when you have multiple Dockerfiles with the same steps (in the same order) because they work as cache.

A longer and more complete explanation can be found here.

Eventually, if you delete your image or change build steps, you could have dangling none images. Those can be deleted, as @Mike mentioned, with:

docker image prune
查看更多
登录 后发表回答