.net - docker dotnet restore error:error mounting "dockercontainers.resolv.conf" to rootfs at "etcres

I am building a .Net 6.0 program in Docker. The project structure is as follows:MyProject├── XXXX.Rep

I am building a .Net 6.0 program in Docker. The project structure is as follows:

MyProject

├── XXXX.Repository

├── XXXX.WebApi

├────── Dockerfile

└── XXXX.sln

My Dockerfile content is as follows:

FROM mcr.microsoft/dotnet/sdk:6.0 AS build
WORKDIR /src

COPY *.sln ./
COPY ["XXXX.WebApi/", "./XXXX.WebApi/"]
COPY ["XXXX.Repository/", "./XXXX.Repository/"]


WORKDIR "/src/XXXX.WebApi"
RUN dotnet restore 

FROM build AS publish
RUN dotnet publish -c Release -o /app/publish

FROM mcr.microsoft/dotnet/aspnet:6.0 
WORKDIR /app
EXPOSE 7777 

COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "XXXX.WebApi.dll"]

My compile command:

cd /MyProject
docker build  -f XXXX.WebApi/Dockerfile -t myapi-img .

When I build the image, the following error occurs:

Step 1/15 : FROM mcr.microsoft/dotnet/sdk:6.0 AS build
 ---> 27ce95112d34
Step 2/15 : WORKDIR /src
 ---> 8acb24c3cfe5
Step 3/15 : COPY *.sln ./
 ---> 933adbefb54e
Step 4/15 : COPY ["XXXX.WebApi/", "./XXXX.WebApi/"]
 ---> 18020079fca0
Step 5/15 : COPY ["XXXX.Repository/", "./XXXX.Repository/"]
 ---> 77480c8f6cdd
Step 6/15 : RUN dotnet restore
 ---> Running in b50c2706738c
OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/data/docker/containers/b50c2706738cff21e132f815d7fb94ea884f5fb51895b64510012c33666854ab/resolv.conf" to rootfs at "/etc/resolv.conf": possibly malicious path detected -- refusing to operate on /etc/resolv.conf: unknown

I have been googling stackoverflow for a long time, but I still can't find a solution.Someone suggested that I adjust /etc/docker/daemon.json as follows:

{
    "registry-mirrors": [
      ";,
      ";,
      ";,
      ";
    ],
    "dns": [
      "172.28.130.123",
      "100.125.108.250",
      "8.8.8.8",
      "114.114.114.114"
    ]
  }

I also adjusted /etc/resolv.conf:

# Generated by NetworkManager
search openstacklocal novalocal
nameserver 172.28.130.123
nameserver 100.125.108.250
nameserver 8.8.8.8
nameserver 114.114.114.114

but the error still occurred.If I don't use docker, everything is normal.

docker Version: 19.03.4

system version: Centos 7.2

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742373280a4431684.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信