for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Unable to prepare context: path "." not found while using OneDrive Files On Demand

Open xposix opened this issue 9 years ago • 16 comments

Expected behavior

Build any image from any directory that contains a Dockerfile file.

Actual behavior

I can't build an image from a folder using new "Filles On Demand" Onedrive feature with Windows 10 Fall Creators Update. I get the error message 'Unable to prepare context: path "." not found' It doesn't work on any of my two computers with this feature enabled. All my Dockerfiles are set to "Always keep on this device" on both devices, but still doesn't work.

It works fine when I move the Dockerfiles out of Onedrive and when I redirect the Dockerfile to the build command, (example: docker build -t test - < Dockerfile)

Information

  • Diagnostic ID from "Diagnose & Feedback" in the menu. 2E1C9248-2442-4E95-A494-A1A3CED026A7/2017-11-06_21-02-18
  • a reproducible case if this is a bug, Dockerfiles FTW
  • page URL if this is a docs issue or the name of a man page
  • host distribution and version (Windows version, build number, etc) Windows 10 Fall Creators Update 17.09 Microsoft OneDrive 17.3.7074.1023

Steps to reproduce the behavior

  1. Install latest version of Windows
  2. Install latest version of Onedrive
  3. Enable the Files on Demand feature
  4. Move Dockerfiles inside Onedrive
  5. try any docker build inside any folder inside Onedrive.

xposix avatar Nov 06 '17 20:11 xposix

The problem still happens when I disable "Files On Demand" option in OneDrive. I cannot build from a file that is being sync by OneDrive. The problem has been reported on #1328 too.

xposix avatar Nov 22 '17 09:11 xposix

Not sure if it will help, but I was having the same problem, decided to create a drive->folder link because i've had some issues with the forced OneDrive folder (not sure if its the spaces or if its not a 'normal' folder) So In my case I went from d:/OneDrive - MyAccount/Code to p:/Code where p was the virtual drive letter I assigned the folder(I used http://www.ntwind.com/software/utilities/visual-subst.html, but you can also use the cmd https://technet.microsoft.com/en-us/library/bb491006.aspx) and the problem went away. It still syncs properly and i'm able to build within the OneDrive directory so long as i run the docker command from the p: drive location.

Just trying to share a potential workaround. Hope it helps.

sampaioletti avatar Dec 07 '17 22:12 sampaioletti

Hello,

It seems that upgrading to the latest version released today (17.12.0-ce-rc2-win41 (14746)) the issue is gone. Can anyone else confirm that building images from OneDrive for Business paths is working with the latest version?

tdabasinskas avatar Dec 14 '17 07:12 tdabasinskas

I still have the issue on my Windows 10 desktop if I create a folder on One Drive folder docker build fails "unable to prepare context: unable to evaluate symlinks in context path: readlink C:\Users\cc\OneDrive - Microsoft\git\xxx\Docker: The process cannot access the file because it is being used by another process."

Moving that folder to another folder outside of onedrive don't remove the error. Looks like there is a metadata on the folder saying it was created by OneDrive... "unable to prepare context: unable to evaluate symlinks in context path: readlink C:\Users\cc\git\xxx\Docker: The process cannot access the file because it is being used by another process."

if I create a folder outside of OneDrive, moving my code, it is working fine and I can build the image (i.e c:\docker).

Default Isolation: hyperv Kernel Version: 10.0 16299 (16299.15.amd64fre.rs3_release.170928-1534) Operating System: Windows 10 Enterprise

The version of docker is: Version 17.12.0-ce-win46 (15048) Channel: stable 0ac7325

LaurentLesle avatar Jan 11 '18 13:01 LaurentLesle

@sampaioletti I tried out your proposed workaround to no avail. I still get the error. I.e. unable to prepare context: unable to evaluate symlinks in context path: readlink Z:\Projects: The process cannot access the file because it is being used by another process.

Windows 10.0.16299 Docker 17.12.0-ce-win47 (15139) Linux containers

cveld avatar Jan 16 '18 22:01 cveld

@sampaioletti Tried your workaround but having the same issue. "unable to prepare context: unable to evaluate symlinks in context path: readlink Z:\docker: The system cannot find the file specified." Any help with this would be highly appreciated. Thank you,

Docker version 18.01.0-ce, build 03596f51b1 Windows 10.

anishsunkara avatar Jan 20 '18 06:01 anishsunkara

I'm facing a similar issue, everything I read says docker doesn't really support adding items from outside the build context. The workaround I have seen is to build from the directory you want to copy files and supply -f to the dockerfile rather than building . I'm thinking to have a build.ps1 (and build.cmd wrapper for ease) and an ARG in the dockerfile which the ps1 can feed the $PSScriptRoot into enabling a combination of both external directory and items co-located with the dockerfile..... will let you know if I get anywhere.

willwhite1 avatar Mar 30 '18 13:03 willwhite1

Ok, I ended up doing the following... not sure if it helps or not. I have a folder container my docker project - C:\projects\willsdocker I have another folder containing some items I was to COPY/ADD to container - C:\something

In my docker project I created a build script - C:\projects\willsdocker\build.ps1 This script takes in mandatory param 'artifactPath' (so 'C:\something' in this example) I copy 'this' to a new directory created in the artifactPath Parent - C:\dockertmp then my docker build command works by specifying -f and .. for context - docker build -f "$($newDir)/Dockerfile" .. -t something

Obviously your Dockerfile COPY/ADD commands have to cater for relative references based on the above solution.

willwhite1 avatar Mar 30 '18 14:03 willwhite1

Anyone fixed this? I'm getting this error when i run command docker build to a dockerfile in C:, the Dockerfile ok, not have extension like .txt and is in folder that i make the command. Windows 10, Docker version latest

Leonardo18 avatar Apr 18 '18 11:04 Leonardo18

Tried with Docker Toolbox, and it throws the same error...

vladvarna avatar Apr 24 '18 14:04 vladvarna

I'm not sure docker consider it to be an error, but rather an explicit design principle.... you can work around it by wrapping your docker build command into a build script which organizes the file system prior to docker build invocation.... that is what I ended up having to do.

willwhite1 avatar Apr 24 '18 15:04 willwhite1

I had the same problem and solved it similarly to what @willwhite1 did, where I created a temporary folder to which I pointed docker build for its context and then copied all the files docker build needed to this folder. It seems it's enough to create a new folder, even a sub folder in OneDrive, for this "locking" problem to go away, at least for a smaller example project. Maybe there could be other issues with larger projects in which case I'd recommend creating a temporary folder in the home directory.

christian-eriksson avatar Apr 27 '18 14:04 christian-eriksson

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

docker-robott avatar Jul 31 '18 01:07 docker-robott

/remove-lifecycle stale

michha avatar Aug 31 '18 09:08 michha

I still have this problem.

MrGlaurung avatar Apr 01 '19 08:04 MrGlaurung

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked

docker-robott avatar Jun 24 '20 03:06 docker-robott