Dockerfile with copy command and relative path
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.
TitaoYamamoto
Updated on June 19, 2022Comments
-
TitaoYamamoto almost 2 years
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
-
TitaoYamamoto over 5 yearsHi @Kuanlin Chen, Im using docker-compose and I need to do this inside the Dockerfile. Do you know another way to do that?
-
Corey over 5 yearsHi @TitaoYamamoto I have updated my answer, please have a try.