Dockerfile with copy command and relative path

Viewed 16979

Have same way to use copy command with relative path in dockerfile? Im trying to use:

COPY ./../folder/*.csproj ./

OBS.: My struct folder (Im running the dockerfile on project-test and another files is in project-console folder) is:

|- project-console

|- project-test

And Im receive the follow error:

ERROR: service 'app' failed to build: COPY failed: no source files were specified.

My purpose is have two projects in the same docker. I have a dotnet core console and another with unity test (NUnity), Im trying run the unity test in docker.

UPDATE

Is possible to use Multi-stage: https://docs.docker.com/develop/develop-images/multistage-build/

Or using docker-compose with build: https://docs.docker.com/engine/reference/commandline/build/

Like:

services: 

worker:
    build:
      context: ./workers
      dockerfile: Dockerfile
1 Answers

Reference: Allow Dockerfile from outside build-context

You can try this way

$ cd project-console
$ docker build -f ../project-test/Dockerfile .

Update:

By using docker-compose

build:
  context: ../
  dockerfile: project-test/Dockerfile

../ will be set as the context, it should include project-console and project-test in your case. So that you can COPY project-console/*.csproj in Dockerfile.

Related