Reputation: 5129
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
Upvotes: 3
Views: 16716
Reputation: 32156
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.
Upvotes: 7
Reputation: 14823
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/
Upvotes: 3