Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I recently upgraded my .NET Core web application projects to .NET Core 2.1, following the upgrade guide suggested.

I also updated my Dockerfiles - one to use the alpine runtime image as a base, and one to use the standard aspnet runtime image as a base. However, when running these on a Docker host running on Centos 7.4, they instantly fail with the message "Access to the path '/proc/1/map_files' is denied". The images are built on the same machine they are running on.

When built & run on Windows, there is no problem. When the images built on Centos are imported into Docker for Windows they are running fine. It's only on the Centos docker host that this problem arises.

I've filed an issue on Github here , and found a similar issue here , but the only solution given was to use a working directory (which I tried, and didn't work).

No idea what's going on here but hopefully someone has run into this before.

The docker files are

FROM microsoft/dotnet:2.1.2-aspnetcore-runtime-alpine3.7
COPY /publish/ .
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
RUN mkdir web-data
RUN mkdir web-data/my-api
ENTRYPOINT ["dotnet", "My.Api.dll"]
FROM microsoft/dotnet:2.1.2-aspnetcore-runtime
COPY /publish/ .
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENV REDIS_URL redis
ENV REDIS_PORT 6379
ENV REDIS_KEY_NAME DataProtection-Keys
ENV DP_CERT_PATH /etc/ssl/dotnet/dp-cert.pfx
RUN mkdir web-data
RUN mkdir web-data/my-app
# this is required in order to create Excel reports
RUN apt-get update
RUN apt-get install -y libgdiplus
ENTRYPOINT ["dotnet", "My.App.dll"]

The docker run commands are as follows

docker run -d -e ASPNETCORE_ENVIRONMENT=Dev -e DP_CERT_PASS=123xyz \
--name my-app --net app-web  \
--mount source=logs,target=/etc/logs --mount source=web-data,target=/web-data \
--mount source=dp-certs,target=/etc/ssl/dotnet \
--restart always my-app:1.0.0
                Our team spent all morning trying to figure this one out. We are also running a .net core C# web app on Docker on CentOS.  When we were copying the application to the root level in the container using .net core 2.0, it did not crash at the start. But it accumulated inotify_add_watch and eventually failed with no "space left on device".  On .net core 2.2, the container crashed with the '/proc/1/map_files' is denied message at the start up time.  Your fix of moving the application to /app folder fixed the issue for both cases, 2.0 and 2.2. Thanks for the solution. Saved us a ton of time!
– Chong Yu
                May 17, 2019 at 21:00
                I had a similar issue in a multi stage builld: The first image also used an working directory /app, but the second one doesn't. After adding WORKDIR /app/ in the second image, the problem was solved.
– Daniel
                Oct 29, 2019 at 8:17

You just need add this "WORKDIR /app" in Dockerfile

I'm compiling dotnet core 2.2 and packing it on Docker runing on CentOS7 server, see my Dockerfile for example its works fine for me:

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-dotnetcore-sdk
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY --from=build-dotnetcore-sdk /app/out .
ENTRYPOINT dotnet poc-dotnet-core-mvc.dll
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.