Because the image is generated based on the Dockerfile in most cases, of course this method is also the officially recommended image generation method because it is easy to reproduce. In the process of generating an image based on the Dockerfile, almost every instruction in the Dockerfile will create a container based on the image generated by the previous instruction, and then execute the content of the instruction to generate a new layer, so except for the one after FROM The most basic mirror layer, the rest can be seen as the superposition of all operations performed on the writable layer, which cannot be deleted. If you feel that some layers are unnecessary, it is recommended to check the image log: docker history ImageName, and then write your own Dockerfile based on the log content to remove unnecessary steps. Then the rebuilt image will not have layers that you do not need. I wish you success.
If the image layer already exists, it will not be downloaded repeatedly.
To use a certain image, you need to download all the layers, and the middle layer is also necessary
Just delete what you don’t need
docker images
,找到没的,然后docker rmi <image_id>
Because the image is generated based on the Dockerfile in most cases, of course this method is also the officially recommended image generation method because it is easy to reproduce. In the process of generating an image based on the Dockerfile, almost every instruction in the Dockerfile will create a container based on the image generated by the previous instruction, and then execute the content of the instruction to generate a new layer, so except for the one after FROM The most basic mirror layer, the rest can be seen as the superposition of all operations performed on the writable layer, which cannot be deleted. If you feel that some layers are unnecessary, it is recommended to check the image log: docker history ImageName, and then write your own Dockerfile based on the log content to remove unnecessary steps. Then the rebuilt image will not have layers that you do not need. I wish you success.