Putting curly braces around your variables, instead of just in potentially ambiguous cases, can be considered good programming practice. So, try the curly braces. This worked for me.
UPDATED ANSWER:
Sorry, I should have tested the values that YOU provided. Yeah, to make it work I had to wrap C:\path\ in single quotes:
FROM centos:latest ARG destpath='C:\path\' ARG javafile=java.exe ARG javapath=${destpath}${javafile} RUN echo $javapath
Result:
$ docker build -t temp . Sending build context to Docker daemon 2.048kB Step 1/5 : FROM centos:latest ---> e934aafc2206 Step 2/5 : ARG destpath='C:\path\' ---> Running in 61f1aa0ea477 Removing intermediate container 61f1aa0ea477 ---> f49332bb07f9 Step 3/5 : ARG javafile=java.exe ---> Running in 7f965bea7edf Removing intermediate container 7f965bea7edf ---> b1d66e9b07ff Step 4/5 : ARG javapath=${destpath}${javafile} ---> Running in 9cfb4e2274f3 Removing intermediate container 9cfb4e2274f3 ---> 65dc408e384b Step 5/5 : RUN echo $javapath ---> Running in 7906c930caef C:\path\java.exe ##################################### there you go Removing intermediate container 7906c930caef ---> 887ef91def32 Successfully built 887ef91def32 Successfully tagged temp:latest
OLD ANSWER:
FROM centos:latest ARG destpath=hello ARG javafile=world ARG javapath=${destpath}${javafile} RUN echo $javapath
My result was as following:
$ docker build -t temp . Step 1/5 : FROM centos:latest ---> e934aafc2206 Step 2/5 : ARG destpath=hello ---> Running in 30f047122373 Removing intermediate container 30f047122373 ---> 582d3a801fd0 Step 3/5 : ARG javafile=world ---> Running in 78817656b729 Removing intermediate container 78817656b729 ---> a3afa410e42e Step 4/5 : ARG javapath=${destpath}${javafile} ---> Running in 8baf8c862572 Removing intermediate container 8baf8c862572 ---> 1a9c012e4d57 Step 5/5 : RUN echo $javapath ---> Running in 48ee08e6452d helloworld ############################################## there it is Removing intermediate container 48ee08e6452d ---> 9d72ba2aab67 Successfully built 9d72ba2aab67 Successfully tagged temp:latest
P.S. If this doesn't work, it's windows' fault.