Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using COPY with more than one source file, the destination must be a directory and end with a /

I decided to use the multiple source form of COPY to save an intermediate command but when I run it the following error pops up:

Step 17/22 : COPY --chown=$APP_USER:$APP_USER Gemfile Gemfile.lock $APP_PATH
When using COPY with more than one source file, the destination must be a directory and end with a /

In the Dockerfile I have this:

ARG APP_PATH='/usr/share/app/'

ONBUILD COPY --chown=$APP_USER:$APP_USER Gemfile Gemfile.lock $APP_PATH

Edit

Just to be clear, this happens with ONBUILD present and without, it just so happened I pasted in the ONBUILD example


I've tried with and without the single quotes. The arg has a trailing slash and is a directory so why is the build not honouring it?

I'd like to make this Dockerfile into a template using ONBUILD so it'd be good if I can make sure the APP_PATH arg is populated with a default that will work.

Any help or insight will be much appreciated.

like image 484
ian Avatar asked Dec 06 '18 11:12

ian


2 Answers

in my case was just adding the slash at the end

COPY package*.json .

COPY package*.json ./ (works)

like image 142
Renan Nery Avatar answered Sep 21 '22 17:09

Renan Nery


The answer, as of Docker version 18.09.0, build 4d60db4, is don't do it this way because it won't work.

I ended up hard-coding the destination directory (and the chown args too):

ONBUILD COPY --chown=app:app Gemfile Gemfile.lock /usr/share/app/
like image 29
ian Avatar answered Sep 20 '22 17:09

ian