When building a Dockerfile I often allow arguments to be configured at build time to make it easier to build only a few different containers. To do this, I use the default values ββfor ENV vars in combination with user-defined ARG s. Dockerfile example for quick testing:
FROM busybox ARG FLAGS ENV FLAGS ${FLAGS:-} RUN echo "${FLAGS}"
This can be used as follows:
docker build --build-arg FLAGS="foo --remove-me" -t <imagename>:<tag> .
Now I am in a situation where I want to actively remove a certain flag (in the above example: --remove-me ) from the command that I allow to run (due to an error that has been fixed no more than a year), although I know how to remove flag in other situations:
LC_ALL=C sed -e 's/ --remove-me//'
I ran into a problem that I have no idea how to pass and remove a flag. I know that I can do this when using RUN , but then I would have to repeat above sed using for each RUN statement, so without making it repeatable.
source share