问题描述
我有一个Windows Docker容器( microsoft / aspnet
),该容器托管一个简单的Web API。 Web API接受来自表单的文件,将它们保存在temp文件夹中,进行一些处理,然后返回结果。
I've got a Windows Docker container (microsoft/aspnet
) that is hosting a simple Web API. The web API accepts files from a form, saves them in a temp folder, does some processing, and then returns the result.
在本地部署时工作正常,但是当在Docker容器中完成后,我的临时文件夹( App_Data
)出现文件权限错误。
This works fine when deployed locally, but when done in my Docker container, I get a file permissions error on my temp folder (App_Data
).
是一种向IIS用户授予代码正在作为对此文件的访问权而运行的方法,还是向任何用户打开该文件夹以进行读/写访问的权限?
Is there a way to grant the IIS user the code is running as access to this file, or to open up the folder to any user for read/write access?
当前Docker文件如下所示:
Current Docker file is below:
FROM microsoft/aspnet
COPY ./Deploy/ /inetpub/wwwroot
RUN mkdir /inetpub/wwwroot/App_Data
错误消息片段我正在运行API来自docker映像:
Error message snippet I get running API from docker image:
"InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Access to the path 'C:\\inetpub\\wwwroot\\App_Data\\BodyPart_481b6424-f9a5-4608-894d-406145a48445' is denied.","ExceptionType":"System.UnauthorizedAccessException"
在aspnet-docker github上似乎有一个关于同一问题的错误开放。
It looks like there is a bug open on the aspnet-docker github about this same issue. [link]
与此同时,启动容器后,似乎运行 cacls App_Data / G IIS_IUSRS:F
可以临时解决问题。
In the meantime, it looks like running cacls App_Data /G IIS_IUSRS:F
after starting the container fixes the issue temporarily.
推荐答案
不清楚原因,但是 cacls
在作为构建容器的一部分运行时似乎不起作用。切换为使用 icacls
,并且能够授予该文件夹的 IIS_USRS
权限。
Unclear why, but cacls
doesn't seem to be working when run as part of building the container. Switched to using icacls
, and was able to grant the IIS_USRS
permissions on the folder.
添加到dockerfile的行:
Line added to dockerfile:
运行icacls'C:\inetpub\wwwroot\App_Data'/授予'IIS_IUSRS:(F)'
这篇关于Windows容器中的容器文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!