I have a Dockerfile where an ARG
is used in the CMD
instruction:
ARG MASTER_NAME
CMD spark-submit --deploy-mode client --master ${MASTER_URL}
The arg is passed via docker-compose:
spark:
build:
context: spark
args:
- MASTER_URL=spark://master:7077
However, the ARG
does not seem to get expanded for CMD
. After I docker-compose up
.
Here's what inspect shows:
docker inspect -f "{{.Name}} {{.Config.Cmd}}" $(docker ps -a -q)
/spark {[/bin/sh -c spark-submit --deploy-mode client --master ${MASTER_URL}]}
The thing is that
args
only can be used at build time, and theCMD
is executing at run time. I guess that the only approach now to achieve what you want is setting an environment variable in the Dockerfile with theMASTER_NAME
value.