【问题标题】:Check for unused/uncessary packages in Docker检查 Docker 中未使用/不必要的包
【发布时间】:2022-02-04 06:21:21
【问题描述】:

TL;DR: 有没有一种方便的方法来扫描 docker 映像以查找未使用/不必要的包。

问题:给定大量 docker 图像和文件,是否可以扫描它们并检查是否正在使用包?为了安全起见,最好删除所有不必要的包并减少任何攻击面。在特别大的应用程序中,开发人员意外留下以前有用的包的情况并不少见。

潜在的脏方法: 一个一个地删除包,如果应用程序构建失败,那么我们把那个包放回去,认为有必要。但是,如果 docker 文件构建成功,它可能会触发一个通知,指示该包可能未使用。

【问题讨论】:

  • 您如何区分未使用的包和尚未使用的包?我不确定如何在不研究应用程序的情况下正确测试应用程序的需求,此时您会知道通过学习应用程序可以删除哪些包。

标签: docker docker-compose package dockerfile scanning


【解决方案1】:

关于未使用的图像,您可以使用命令docker image prune

这里是 link 到可能对您有帮助的文档。

nabil@LAPTOP:~$ docker image help

Usage:  docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Run 'docker image COMMAND --help' for more information on a command.

【讨论】:

  • 我认为这个问题与 docker 映像中的包有关。我正在追求类似的东西。
猜你喜欢
  • 2021-08-16
  • 1970-01-01
  • 2023-03-24
  • 2017-01-11
  • 1970-01-01
  • 2018-11-08
  • 1970-01-01
  • 1970-01-01
  • 2018-05-04
相关资源
最近更新 更多