Bash Bracket extension does not work on Dockerfile RUN command

In my Docker file, the following RUN command is executed, awaiting the creation of a "logs" directory 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 

But when I check the image, I see a directory that is literally called "{diameter-env, h248-env, http-env, msrp-env, octcap-env, radius-env, sip-env, synchro-env, xcap-env } "created in / opt / seagull, instead of expanding the bracket.

What can i do wrong?

+5
source share
1 answer

You are not using the brace extension because you are not using Bash. If you look at the documentation for the RUN command :

RUN (shell form, the command runs in the shell, which by default is / bin / sh -c on Linux or cmd / S / C on Windows)

And:

Note. To use a different shell other than '/ bin / sh, use the exec form that runs in the desired shell. For example, RUN ["/ bin / bash", "-c", "echo hello"]

So, just change the command to use the exec form and explicitly use the 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" ] 
+10
source

Source: https://habr.com/ru/post/1258567/


All Articles