CentOS8 虚拟机上docker build项目错误问题
之前一直是再IIS部署,为了顺应asp.net core 跨平台这个特性,开始学习docker 一些东西。然而在部署时总是遇到各种问题。今天这个问题耗费了我很场时间最终解决:
标志性错误如下:
Unable to load the service index for source http://api.nuget.org/v3/index.json
Determining projects to restore... /usr/share/dotnet/sdk/5.0.100/NuGet.targets(131,5): error : Unable to load the service index for source http://api.nuget.org/v3/index.json. /usr/share/dotnet/sdk/5.0.100/NuGet.targets(131,5): error : Resource temporarily unavailable (api.nuget.org:80) /usr/share/dotnet/sdk/5.0.100/NuGet.targets(131,5): error : Resource temporarily unavailable
此问题由于刚开始学习,又是使用刚刚最新版本.net5,出现问题以后网络找了很久就没有实质性解决,问了一些人也是回到牛头不对马嘴,最后根据网络一些文章判断,有可能是docker 连不上网络。解决办法如下:
docker build -t bbs . --network=host
--network=host 这个很重要,意思指定网络:
可以使用如下命令查看网络列表:
docker network ls
最后运行访问成功