根据建议的升级指南,我最近将.NET Core web应用程序项目升级到.NET Core 2.1。
我还更新了Dockerfiles—一个使用alpine运行时图像作为基础,另一个使用标准aspnet运行时图像作为基础。但是,在Centos 7.4上运行的Docker主机上运行这些文件时,它们会立即失败,并显示消息“拒绝访问路径“/proc/1/map_files”。这些图像构建在它们运行的同一台机器上。
在Windows上构建和运行时,没有问题。当Centos上构建的图像导入Docker for Windows时,它们运行良好。只有在Centos docker主机上才会出现这个问题。
我在Github上提交了一个问题
here
,并发现了类似的问题
here
,但给出的唯一解决方案是使用工作目录(我尝试过,但没有成功)。
不知道这里发生了什么,但希望有人以前遇到过。
docker文件是
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"]
docker run命令如下
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