Docker Community Forums

Share and learn in the Docker community.

ADD failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder857651318\bin\Debug\netcoreapp2.0\publish: The system cannot find the path specified.


(Geedsen) #1

I have this simple dockerfile in my VS directory:

FROM microsoft/aspnetcore:2.0-nanoserver-1709
ADD bin/Debug/netcoreapp2.0/publish/ /
ENTRYPOINT myfile.exe

From powershell, I go to the directory with the solution.
I then build the application.

dotnet publish -c Release

Works fine. I then build the image:

docker build -t xpndr.ats.release --build-arg source=bin/Release/netcoreapp2.0/publish .

Works fine as well, I can see the image doing a “docker images”

But when I run the image I get an error that myfile.exe cannot be found.
Correct , it is a core dll. So I change the ENTRYPOINT to [“dotnet”,“myfile.dll”]
I also add a .dockerignore file with the follwoing:

directories
**/bin/
**/obj/
**/out/

files

Dockerfile*
**/.trx
**/
.md
**/.ps1
**/
.cmd
**/*.sh

And I then rebuild the image

docker build -t xpndr.ats.release --build-arg source=bin/Release/netcoreapp2.0/publish .

ending up with the following error:

Sending build context to Docker daemon 30.72kB
Step 1/3 : FROM microsoft/aspnetcore:2.0-nanoserver-1709
—> 882104b1a10d
Step 2/3 : ADD bin/Debug/netcoreapp2.0/publish/ /
ADD failed: CreateFile \?\C:\ProgramData\Docker\tmp\docker-builder857651318\bin\Debug\netcoreapp2.0\publish: The system cannot find the path specified.

So I removed the .dockerignore, same error

Modified the dockerfile to its original, same error

And what ever I do I always het this error.


(Aligneddev) #2

The answer here helped me: COPY failed trying to install plain Asp.Net MVC app to a container

I also added that as an answer here: https://stackoverflow.com/questions/49803536/vs-2017-copy-failed-docker-file-createfile-the-system-cannot-find-the-file-spe/52414795#52414795


(Abhayondocker) #3

Hi I have faced this and lost 2 days investigating why COPY and ADD is not working. But I found a solution how COPY and ADD command works in a docker window container. Hope this solution will save some of your time.

1 - ADD and COPY command with source path containing some path other than current folder never works in window container. It should be always
ADD ./filename .
COPY ./filename .
It means copy the image from current directory . If you give any path like
ADD bin/Debug/netcoreapp2.0/publish/ / it always tries to create a directory in \?\C:\ProgramData\Docker\tmp\docker-builder857651318`bin\Debug\netcoreapp2.0\publish`

That means the path you give in source directory will appended and try to create file or folder inside docker random folder (docker-builder857651318) which does not exists. in your case bin\Debug\netcoreapp2.0\publish is always getting appended where nothing exists… So to make COPY and ADD work in docker container do not give any folder path in source path.

2 - Here are steps for clean approach to fix this issue
Create a new folder.
Copy your jar or image in that folder.
Create a Dockerfile in that folder
Give the path like
ADD ./filename .
COPY ./filename .

It means copy from Local folder (./filename) to docker current deployment(.) folder. That works