问题描述
我正在Dockerfile中运行以下RUN命令,期望在每个列出的子目录下创建一个日志目录:
I'm running the following RUN command in my Dockerfile, expecting a "logs" directory to be created under each of the listed subdirectories:
RUN mkdir -p /opt/seagull/{diameter-env,h248-env,http-env,msrp-env,octcap-env,radius-env,sip-env,synchro-env,xcap-env}/logs
但是,当我检查图像时,我看到一个目录,其名称为 {diameter-env ,h248-env,http-env,msrp-env,octcap-env,radius-env,sip-env,synchro-env,xcap-env}创建,而不是进行括号扩展。
But when I check the image, I see a directory literally called "{diameter-env,h248-env,http-env,msrp-env,octcap-env,radius-env,sip-env,synchro-env,xcap-env}" created under /opt/seagull, instead of brace expansion taking place.
我在做什么错了?
推荐答案
您没有使用大括号扩展,因为您没有使用Bash。如果您查看:
You're not using brace expansion, because you're not using Bash. If you look at the documentation for the RUN command:
而且:
因此,只需更改命令来使用exec表单并显式使用Bash shell:
So, just change the command to use the exec form and explicitly use a Bash shell:
RUN [ "/bin/bash", "-c", "mkdir -p /opt/seagull/{diameter-env,h248-env,http-env,msrp-env,octcap-env,radius-env,sip-env,synchro-env,xcap-env}/logs" ]
这篇关于Bash大括号扩展不适用于Dockerfile RUN命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!