Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose not finding my files

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

like image 936
Matt Avatar asked May 04 '26 00:05

Matt


1 Answers

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:

  1. Change the context to .
  2. Change the path to NuGet.config to also contain the current folder name: root/NuGet.config

I would recommend the first approach as from your question I don't see any reason you would want to refer to the parent folder.

like image 169
Alexandru Pirvu Avatar answered May 06 '26 15:05

Alexandru Pirvu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!