Hi All,
Is there a way to execute COPY only if the file exists on the host?
Maybe there is a way to do that check from a shell script that is executed in Dockerfile…
Thanks,
Alex.
Share and learn in the Docker community.
Hi All,
Is there a way to execute COPY only if the file exists on the host?
Maybe there is a way to do that check from a shell script that is executed in Dockerfile…
Thanks,
Alex.
Hi,
COPY instruction in Dockerfile expects a file to exist in the source location mentioned. If the source file is not there the build will fail. Dockerfie doesn’t have the feature to conditionally execute instructions.
Regards
You can use wildcards to optionally copy. For example, to COPY a yarn.lock file that may or may not exist, do:
COPY package.json yarn.* /opt/app/
This one from @dylansmith really worked!
Thanks!