0

Within a Dockerfile, I'd like to execute a Dockerfile command (e.g. ADD or COPY etc...) according to a build flag

FROM ...

ARG doit=no

RUN if [ $doit != no ]; then \ ADD foo.tar.gz / ; \ fi

When passing --build-arg doit=something to the docker build command I'd like the foo archive to be expanded in /

I do not seem to be able to execute a Dockerfile command inside a RUN

Any workaround?

  • https://stackoverflow.com/questions/43654656/dockerfile-if-else-condition-with-external-arguments might help – grizzthedj Jul 16 '19 at 18:32
  • use bash consitions – Efrat Levitan Jul 17 '19 at 10:34
  • I understand that I can wrap some logic in a bash script but, within this logic, I'd need to call a Dockerfile command - _e.g. ADD, COPY, etc..._. In essence I am trying to call a Dockerfile command inside an _if ... _ – user2857891 Jul 17 '19 at 12:35

0 Answers0