Docker: COPY failed: CreateFile, looking for file in strange location

Before copying add a volume in your image to copy where to. Something like this:

VOLUME C:/Users/mysolution
COPY my.solution.sln C:/Users/mysolution

Try not to use dots for directory names.


The COPY command will copy the file from the build context, or a previous build stage if you specify the stage. With your build command:

docker build -t my.solution .

The context is . which is first sent to the docker engine which places that in a temporary location just for the build.

Therefore with your copy command:

Step 6/17 : COPY my.solution.sln ./

The file my.solution.sln needs to exist in the folder where the build command was run.

For the destination, the file will be copied to the working directory inside the container, or /src in your example.


Seems to me the standard Dockerfile that comes with a new solution is bugged :/

I moved the Dockerfile up to the solution folder, from PowerShell:

mv Dockerfile ../Dockerfile

Running the docker build command from there did the trick for me...


This was probably caused by the .dockerignore file next to you DockerFile, ignoring everything but /obj/*. Once you copied it to another folder you didn't copy the .dockerignore file, so nothing was excluded and it worked.