Bash brace expansion not working on Dockerfile RUN command

If /bin/bash is available in your image, you can change the shell that the docker build system uses to execute your RUN command, like this:

SHELL ["/bin/bash", "-c"]

Now, your RUN command should work unchanged.


You're not using brace expansion, because you're not using Bash. If you look at the documentation for the RUN command:

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

And also:

Note: To use a different shell, other than ‘/bin/sh’, use the exec form passing 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 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" ]