I want to pass an argument to my dockerfile such that I should be able to use that argument in my run command but it seems I am not able to do so
I am using a simple bash file that will trigger the docker build and docker run
FROM openjdk:8 AS SCRATCH WORKDIR / ADD . . RUN apt install unzip RUN unzip target/universal/rule_engine-1.0.zip -d target/universal/rule_engine-1.0 COPY target/universal/rule_engine-1.0 . ENV MONGO_DB_HOST="host.docker.internal" ENV MONGO_DB_PORT="27017" EXPOSE 9000 ARG path CMD target/universal/rule_engine-1.0/bin/rule_engine -Dconfig.file=$path above is my dockerfile and below is my bash file which will access this dockerfile
#!/bin/bash # change the current path to rule engine path cd /Users/zomato/Documents/Intern_Project/rule_engine sbt dist ENVIR=$1 config="" if [ $ENVIR == "local" ] then config=conf/application.conf elif [ $ENVIR == "staging" ] then config=conf/staging.conf else config=conf/production.conf fi echo $config docker build --build-arg path=$config -t rule_engine_zip . docker run -i -t -p 9000:9000 rule_engine_zip but when i access the dockerfile through bash script which will set config variable I am not able to set path variable in last line of dockerfile to the value of config.

ARGis compiled into the image – think ofdocker buildas similar tosbt distin your setup. If you can update your application to look for the file location in an environment variable rather than a Java property, then you can pass the location using thedocker run -eoption, without rebuilding the image.