I tried to run this below command :
RUN if [ "$someargs" = "AAA" ]; then COPY from/ /usr/local/; fi
I got this error: This command returned a non-zero code: 127
You can't do, inside a
RUN
a Dockerfile
COPY
You need to find another way, you may have a script that creates different Dockerfile based on your test.
As the error states, COPY is not a shell command, it's a docker instruction which is supposed start with a newline.
Syntax -
INSTRUCTION arguments
You can use cp command in Dockerfile. However, you need to COPY the complete directory structure in your image to perform a cp operation. I haven't yet tried this yet but logically it should work.
You can apply the shell logic at your host & use docker cp to actually copy contents from/to host to/from container.
Ref - https://docs.docker.com/engine/reference/builder/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With