Dockerfile ARG substitution in a string in RUN command

Docker doesn’t expand ARG values in the RUN command. Instead, it injects the ARG as an environment variable. The shell itself expands the variable, and all of the Linux shells I’ve used behave differently based on the type of quote.

The single quotes direct the shell not to expand anything, and you only need to escape the single quotes and escape characters. While the double quotes include variable expansion along with many other escape characters. See the man page on your shell for more details.

So the solution as you’ve already found is:

RUN echo "Hello $w"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)