Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将命令输出分配给Dockerfile中的ARG变量_Docker_Environment Variables_Dockerfile_Devops - Fatal编程技术网

将命令输出分配给Dockerfile中的ARG变量

将命令输出分配给Dockerfile中的ARG变量,docker,environment-variables,dockerfile,devops,Docker,Environment Variables,Dockerfile,Devops,我希望在Dockerfile中能够将命令的输出分配给ARG变量。例如: ARG myvar=$(echo 'hello') 然而,这给了我语法错误 ERROR: Dockerfile parse error line 68: ARG requires exactly one argument 有办法解决这个问题吗?你不能这么做。$(…)是一个shell表达式,在Dockerfile中无效(在shell中执行的运行命令的上下文中除外)。谢谢。不管我想用这个做什么,我都会用RUN命令来完成。你不

我希望在Dockerfile中能够将命令的输出分配给ARG变量。例如:

ARG myvar=$(echo 'hello')
然而,这给了我语法错误

ERROR: Dockerfile parse error line 68: ARG requires exactly one argument

有办法解决这个问题吗?

你不能这么做。
$(…)
是一个shell表达式,在Dockerfile中无效(在shell中执行的
运行
命令的上下文中除外)。谢谢。不管我想用这个做什么,我都会用RUN命令来完成。你不能这么做。
$(…)
是一个shell表达式,在Dockerfile中无效(在shell中执行的
运行
命令的上下文中除外)。谢谢。不管我想用这个做什么,我都会用RUN命令来完成。