在 Dockerfile 中执行 dpkg-reconfigure wireshark-common

Doing dpkg-reconfigure wireshark-common inside of a Dockerfile

如何在 Docker 文件中 dpkg-reconfigure wireshark-common

我的 Docker 文件包含: RUN apt-get install wireshark --yes

但是 --yes 不会影响 dpkg-reconfigure wireshark-common 步骤,所以我不清楚如何对屏幕上的问题 Should non-superusers be able to capture packets?.[=15 回答是或什至不是=]

尝试使用 yes 命令。

RUN yes | dpkg-reconfigure wireshark-common

您可以做的另一种尝试是:

RUN echo "y" | dpkg-reconfigure wireshark-common

现在不确定 wireshark 在 dpkg-reconfigure 上要求什么...但是使用此技术您可以发送 "y" 或“1”或您需要的任何内容。

根据您在此处的评论提出的另一种可能的解决方案:

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wireshark

对于最后一个,您将跳过任何交互式 post 安装配置步骤。

对于第一个答案,我无法 运行 tshark 作为非 root 用户。 这是我的解决方案,它接受 'dpkg-reconfigure wireshark-common' 的 "yes" 答案,因此您可以 运行 tshark 作为普通用户:

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tshark
RUN yes yes | DEBIAN_FRONTEND=teletype dpkg-reconfigure wireshark-common
RUN usermod -a -G wireshark yourUserName

将 "yourUserName" 替换为允许 运行 tshark 的用户。