In a Dockerfile that is reused among a number of projects, we use a variable to make it easier to replace the name of the project and its directories. So we have for example:
ARG APP_NAME=myapp
COPY --from=builder app/$APP_NAME-web/target/$APP_NAME*.jar app.jar
But the following command is not working
COPY --exclude=$APP_NAME-web/src/frontend . .
unless I leave the app name static like this:
COPY --exclude=myapp-web/src/frontend . .
then it successfully excludes the dir.
I don’t know if that’s a bug specifically with the --exclude
option from docker/dockerfile:1.7-labs
version or if variable interpolation doesn’t work in options arguments in general.
Docker version 28.0.1, build 068a01e on linux fedora silverblue 41