search

Home  >  Q&A  >  body text

Docker怎么删掉不用的layer?

https://hub.docker.com/_/node/

我直接输入的命令
docker pull node
是不是把所有的node的layer版本都下载下来了?
因为有600M呢···
我怎么删掉不用的呢?

天蓬老师天蓬老师2760 days ago799

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-24 09:14:12

    1. If the image layer already exists, it will not be downloaded repeatedly.

    2. To use a certain image, you need to download all the layers, and the middle layer is also necessary

    3. Just delete what you don’t need docker images ,找到没的,然后 docker rmi <image_id>

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:14:12

    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.

    reply
    0
  • Cancelreply