emoleumassi
emoleumassi

Reputation: 5129

Docker /bin/sh: COPY: command not found

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

Answers (2)

user2915097
user2915097

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

vivekyad4v
vivekyad4v

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

  1. 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.

  2. 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

Related Questions