问题描述
Docker 1.9允许将参数传递给dockerfile。请参见链接:
Docker 1.9 allows to pass arguments to a dockerfile. See link: https://docs.docker.com/engine/reference/builder/#arg
我如何在ENTRYPOINT指令中传递相同的标签?
How can i pass the same arugments within ENTRYPOINT Instruction??
我的dockerfile具有
My dockerfile has
在使用上述dockerfile创建容器时出现错误。
请提出在ENTRYPOINT指令中指定参数的正确方法是什么?
I am getting an error while creating container with above dockerfile.Please suggest what is the correct way to specify the argument within ENTRYPOINT instruction??
推荐答案
像 Blake Mitchell 说,您不能在 ENTRYPOINT
中使用 ARG
。但是,您可以将 ARG
用作 ENV
的值,这样就可以将其与 ENTRYPOINT :
Like Blake Mitchell sais, you cannot use ARG
in ENTRYPOINT
. However you can use your ARG
as a value for ENV
, that way you can use it with ENTRYPOINT
:
Dockerfile
ARG my_arg
ENV my_env_var=$my_arg
ENTRYPOINT echo $my_env_var
并运行:
docker build --build-arg "my_arg=foo" ...
这篇关于如何将ARG值传递给ENTRYPOINT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!