24

COPY/ADD statement requires 2 parameters. How can I add any file to current workdir that has been set in base image?

FROM company/app
COPY local.conf

Sure I can add WORKDIR statement before COPY to explicitly declare it. But that would be problematic if the workdir in company/app changes.

2 Answers 2

37

It turns out to be very simple. I just need to use dot to copy to current workdir.

COPY local.conf .

Still cannot figure out if this has some gotchas. But it just work as intended.

1
  • 2
    That should be correct. Don't think there are any gotchas. You are using a relative path to the WORKDIR as described in the docs for COPY Apr 11, 2018 at 18:20
1

But that would be problematic if the workdir in company/app changes.

Then you would need to pass that workdir as build-time parameter in order to be able to change it from one docker build to the next.
See docker build --build-arg

You would need first to docker inspect company/app (inspec the image) to see if there are any changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.