我一直在关注此tutorial,并且一直在使用VS2019创建Dockerfile。我正在Windows 10上使用Docker Desktop,而我的应用程序'AccountOwnerServer'正在使用Linux容器。从Dockerfile进行构建时,它可以顺利完成步骤1-20,但不会在Powershell中显示以下安全警告:
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
当我使用docker run --rm -it -p 8080:80 codemazeblog/accountowner:build
运行容器时,在powershell中出现以下错误:C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint dazzling_chaplygin (e784aeb7f33b182e39d52e0ea37bb035feb6bcefdc53b0d2f4160dba7ec46a99): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
由于我是Docker的相对新手,所以我不确定到底是什么问题或如何解决它。
Dockerfile
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0-stretch AS build
WORKDIR /src
COPY ["AccountOwnerServer/AccountOwnerServer.csproj", "AccountOwnerServer/"]
COPY ["Contracts/Contracts.csproj", "Contracts/"]
COPY ["Entities/Entities.csproj", "Entities/"]
COPY ["LoggerService/LoggerService.csproj", "LoggerService/"]
COPY ["Repository/Repository.csproj", "Repository/"]
RUN dotnet restore "AccountOwnerServer/AccountOwnerServer.csproj"
COPY . .
WORKDIR "/src/AccountOwnerServer"
RUN dotnet build "AccountOwnerServer.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AccountOwnerServer.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AccountOwnerServer.dll"]
答案 0 :(得分:1)
所以,这是东西。我将您的问题分为两部分,我将一一回答:
第1部分:您将收到一条安全警告“安全警告:您正在Windows上针对非Windows Docker主机构建Docker映像。添加到构建上下文中的所有文件和目录都将带有'- rwxr-xr-x'权限。建议仔细检查并重置敏感文件和目录的权限。“:
答案:Windows和Linux是两种不同的操作系统,并且具有两种不同的方式来维护文件,文件夹及其权限。警告的意思是,由于您构建的docker映像最终将在非Windows平台上运行,因此soo Windows已自动将文件权限设置为'-rwxr-xr-x',这意味着文件具有读取,写入和执行用户权限(-rwxr),执行和读取组权限(-xr),仅执行对其他用户的权限(-x)----有关更多权限的信息,请参见here。它基本上会警告您根据用例设置权限。
第2部分:您在docker run语句中收到的错误:
答案:尝试执行以下操作
谢谢。
答案 1 :(得分:0)
您需要按照此处https://docs.docker.com/docker-for-windows/images/whale-icon-systray-hidden.png
的说明切换到Windows容器答案 2 :(得分:0)
这对我有用
Stop-Service docker
Stop-service hns
Start-service hns
Start-Service docker
docker network prune
我在Windows容器https://stackoverflow.com/a/58422312/270155上遇到了类似的问题