![](/img/trans.png)
[英]Docker Redis start with persistent storage using -v gives error (chown: changing ownership of '.': Permission denied)
[英]Unable to change folder ownership using Chown in docker file
在 dockerfile 中運行chown
時,我無法更改文件夾的所有權。 目前 /app/Data 歸root
所有,我正在嘗試將所有權授予moduleuser
。
這是我的 dockerfile:
FROM microsoft/dotnet:2.1-sdk AS build-env
WORKDIR /app
COPY . ./
RUN dotnet restore Project/Magic.csproj --configfile ./NuGet.Config
RUN dotnet publish Project/Magic.csproj -c Release -o out
FROM microsoft/dotnet:2.1-runtime-stretch-slim
WORKDIR /app
COPY --from=build-env /app/Magic/out ./
RUN mkdir /sqlite
RUN chmod 777 /sqlite
RUN useradd -ms /bin/bash moduleuser
RUN chown -R moduleuser:moduleuser /app/Data
USER moduleuser
ENTRYPOINT ["dotnet", "Magic.dll"]
構建映像時, RUN chown -R moduleuser:moduleuser /app/Data
不會引發錯誤。
Step 12/14: RUN chown -R moduleuser:moduleuser /app/Data ---> Running in f02802d1bb5a Removing intermediate container f02802d1bb5a ---> 1558b0aaf823 Step 13/14: USER moduleuser
當我檢查 /app/Data 的所有權時,它仍然顯示root
。
moduleuser@cdcc6f8b78bc:/app/Data$ ls -ld drwxr-xr-x 2 root root 4096 Oct 29 00:06.
如果我在容器內運行 go 並運行chown -R moduleuser:moduleuser /app/Data
,這確實有效並且所有權切換到moduleuser
但由於某種原因它無法通過 dockerfile 工作。
我在這里想念什么?
/app/Data 是 fat32 分區的掛載點嗎? 在這種情況下它不會起作用,因為 fat32 沒有實現所有權。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.