Docker is telling me it cant find the specified file. Is my context wrong? My folder structure is as follows.
root
- docker
- docker-compose-service.yml
- service
- DockerFile
Nuget.config
Inside my docker-compose-service.yml file I have
build:
context: .
dockerfile: ../service/DockerFile
I run from the root folder the following command
docker-compose -f docker/docker-compose-service.yml up --build
It can find the Dockerfile as it runs the code but fails on a line inside the dockerFile which is
COPY NuGet.config .
The error is
failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder408021827/NuGet.config: no such file or directory
What am I doing wrong? I played around with the context and dockerFile location but then it couldn't find the DockerFile
Hmm so if I run the command from the docker folder and change the docker-compose-service.yml file to be
context: ../
dockerfile: service/DockerFile
That seems to work
The path specified in your docker file sets the context as the parent folder of the compose file. In order to make it work, you need to either:
. NuGet.config to also contain the current folder name: root/NuGet.configI would recommend the first approach as from your question I don't see any reason you would want to refer to the parent folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With