Docker Compose 未能构建-文件共享已被取消

我遇到了一个问题与 Docker 桌面,目前即时运行的边缘版本作为一个用户在 Stackoverflow。之前我得到的驱动器没有共享的原因不明错误,这是“解决”的安装边缘版本: Docker for Windows: 驱动器共享由于未知原因失败

现在这个已经安装了,我得到了这个新的错误,这个错误阻止了一些容器的构建。这些容器都经过了测试,可以在其他几个系统上工作。目前4个集装箱中有3个没有建成,它们都产生了如下相同的错误:

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.

完全错误:

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.

以前有人遇到过这个问题并找到了解决方案吗?

57019 次浏览

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

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

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!

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.

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.