Reputation:
I have been following this tutorial and I have been using VS2019 to create a Dockerfile. I am using Docker Desktop on Windows 10 and my application 'AccountOwnerServer' is using Linux Containers. When building from the Dockerfile it successfully goes through steps 1 - 20 with no problems but prints the following Security warning in 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.
When I run the container with docker run --rm -it -p 8080:80 codemazeblog/accountowner:build
I get the following error in 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.
I'm not sure what is wrong exactly or how to fix it as I am a relative novice on 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"]
Upvotes: 1
Views: 6806
Reputation: 527
So, here's the thing. I have divided your question in 2 parts, I will answer them one by one:
Part 1: You get a security warning "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.":
Answer: Windows and Linux are two different operating systems and have 2 different ways to maintain files, folders and their permissions. What the warning is trying to say is that since your building the docker image that will eventually run on a platform that is non-windows, soo windows has automatically set the file permissions to '-rwxr-xr-x' which means the files have read, write and execute permission for user (-rwxr), execute and read for groups (-xr) and just execute permission for others (-x) ---- See here for more knowledge on permissions. It basically warns you to set the permissions according to your use case.
Part 2: The error you are receiving in the docker run statement:
Answer: Try doing the following
Upvotes: 0
Reputation: 6581
This worked for me
Stop-Service docker
Stop-service hns
Start-service hns
Start-Service docker
docker network prune
I had similar issues with Windows containers https://stackoverflow.com/a/58422312/270155
Upvotes: 0
Reputation: 1119
You need to switch to Windows container as mentioned here https://docs.docker.com/docker-for-windows/images/whale-icon-systray-hidden.png
https://docs.docker.com/docker-for-windows/.
Upvotes: 0