如何将参数传递给 Dockerfile? [英] How to pass arguments to a Dockerfile?
本文介绍了如何将参数传递给 Dockerfile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Dockerfile
中使用 RUN 指令来安装 rpm
I am using RUN instruction within a Dockerfile
to install a rpm
RUN yum -y install samplerpm-2.3
但是,我想将值2.3"作为参数传递.我的 RUN 指令应该类似于:
However, I want to pass the value "2.3" as an argument. My RUN instruction should look something like:
RUN yum -y install samplerpm-$arg
其中 $arg=2.3
推荐答案
从 Docker 1.9 开始,您正在寻找 --build-arg
和 ARG
指令.
As of Docker 1.9, You are looking for --build-arg
and the ARG
instruction.
查看此文档以供参考.这将允许您将 ARG arg
添加到 Dockerfile
,然后使用
Check out this document for reference. This will allow you to add ARG arg
to the Dockerfile
and then build with
docker build --build-arg arg=2.3 .
这篇关于如何将参数传递给 Dockerfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文