Docker Compose failed to build - Filesharing has been cancelled

WindowsDockerDocker ComposeDocker Desktop

Windows Problem Overview


I've ran into an issue with Docker Desktop, currently im running the edge version as a user on Stackoverflow. Before I got the drive not shared for unknown reason error which was "solved" by installing edge version: https://stackoverflow.com/questions/59555010/docker-for-windows-drive-sharing-failed-for-an-unknown-reason

Now that this was installed im getting this new error which prevents some containers from being built. These containers have all been tested and works on several other systems. Currently 3 out of 4 containers are not built and they all produce the same error as below:

ERROR: for db  Cannot create container for service db: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled"}
Encountered errors while bringing up the project.

full error:

Creating imt2291-part2_www_1 ...
Creating imt2291-part2_phpmyadmin_1 ... done
Creating imt2291-part2_db_1         ...
Creating imt2291-part2_test_1       ... error
Creating imt2291-part2_www_1        ... error
ERROR: for imt2291-part2_test_1  Cannot create container for service test: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled"}

ERROR: for imt2291-part2_www_1  Cannot create container for service www: status Creating imt2291-part2_db_1         ... error
lled"}

ERROR: for imt2291-part2_db_1  Cannot create container for service db: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled"}

ERROR: for test  Cannot create container for service test: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled"}

ERROR: for www  Cannot create container for service www: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled"}

ERROR: for db  Cannot create container for service db: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled"}
Encountered errors while bringing up the project.

Has anyone encountered this issue before and found a fix?

Windows Solutions


Solution 1 - Windows

You need to update File Sharing configuration in your Docker for Windows app (there is a new security hardening in 2.2.0.0 which has agressive defaults). Add all folders you need and then restart Docker for Windows.

example

Solution 2 - Windows

After changing "File Sharing" to C Drive its start working in my windows machine. I am using docker desktop 2.3.0.3

enter image description here

Solution 3 - Windows

I am using Docker in Windows 10 and had the same problem.
The solution suggested by Oleg Nenashev and Rejoanul Alam helped me.
Adding the project dir where the Dockerfile lives or C:/ to docker shared folders solves the problem.

Step 6 from Getting started states:
> Shared folders, volumes, and bind mounts
If your project is outside of the Users directory (cd ~), then you need to share the drive or location of the Dockerfile and volume you are using.
If you get runtime errors indicating an application file is not found, a volume mount is denied, or a service cannot start, try enabling file or drive sharing.
Volume mounting requires shared drives for projects that live outside of C:\Users (Windows) or /Users (Mac), and is required for any project on Docker Desktop for Windows that uses Linux containers.
For more information, see File sharing on Docker for Mac, and the general examples on how to Manage data in containers.
If you are using Oracle VirtualBox on an older Windows OS, you might encounter an issue with shared folders as described in this VB trouble ticket. Newer Windows systems meet the requirements for Docker Desktop for Windows and do not need VirtualBox.

Solution 4 - Windows

I have meet this problem and my environment is windows. first when the issue happen, I chance the file sharing path to C: , and my project path is in G: ,so the command docker-compose up fail,and the massage is: docker: Error response from daemon: status code not OK but 500 {"Message":"Unhandled exception: Filesharing has been cancelled"}

I think the file sharing must include your project path. because when I set my file sharing path in other file path , it doesn't work, however, i chance it to the path where is my project path, docker-compose up do successfully!

Solution 5 - Windows

I had the same error and answers of Oleg Nenashev and Rejoanul Alam helped me to solve this error.

My task was to share volumes between containers.

I have a website folder with file index.html inside: enter image description here

Open Docker Desktop Settings and write the address of the folder you are working with in File Sharing:enter image description here

After this open this folder in your command prompt and add the necessary Docker command: enter image description here

If the command is correct and you did all steps attentively it must be working fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioninfrozView Question on Stackoverflow
Solution 1 - WindowsOleg NenashevView Answer on Stackoverflow
Solution 2 - WindowsRejoanul AlamView Answer on Stackoverflow
Solution 3 - WindowsvelocityView Answer on Stackoverflow
Solution 4 - WindowscatpandaView Answer on Stackoverflow
Solution 5 - WindowsJohnny155View Answer on Stackoverflow