📜  docker remove dungling images (1)

📅  最后修改于: 2023-12-03 14:40:49.554000             🧑  作者: Mango

Docker Remove Dangling Images

In Docker, a dangling image means an image that has no associated container. These images were created via the docker build command, but were not tagged. Over time, these images can accumulate and take up valuable disk space. Therefore, it is important to remove these images periodically.

Removing Dangling Images

To remove dangling images, use the following command:

docker image prune

This command will remove all dangling images.

To force the removal of all dangling images, use the following command:

docker image prune -f
Marking Dangling Images

Before removing dangling images, it may be helpful to mark them for future reference. This can be done using the following command:

docker image ls -qf "dangling=true" | xargs docker image label add "DANGLING"

This command will mark all dangling images with the label "DANGLING".

Conclusion

It is important to periodically remove dangling images to free up disk space. Use the docker image prune command to remove all dangling images, and the docker image ls -qf "dangling=true" | xargs docker image label add "DANGLING" command to mark dangling images for future reference.