如何在 Dockerfile 中正确使用 yum
在你的 Dockerfile 中使用 yum 安装 mkpasswd 包的示例:
Dockerfile_install_mkpasswd
RUN yum -y install mkpasswd && yum -y clean all && rm -rf /var/cache这里有两个基本方面需要记住:
- 使用
yum -y以避免自动构建期间的交互式Y/N问题 - 使用
yum -y clean all && rm -rf /var/cache在调用yum -y install后清理
完整 Dockerfile 示例:
Dockerfile_example
FROM fedora:34
RUN yum -y install mkpasswd && yum -y clean all && rm -rf /var/cacheIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow