【发布时间】:2026-01-30 17:25:02
【问题描述】:
我正在尝试创建一个可以打包 aspnetcore2.0/angular-universal 应用程序的 docker 映像,但由于我的 docker 经验不足,我一直遇到问题。我真的可以使用一些帮助。
这里是dockerfile的内容:
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
COPY *.csproj ./
RUN npm cache clean --force
RUN npm install npm@latest
RUN npm install @angular/cli@latest
RUN npm install @ngtools/webpack@next
RUN node -v
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM microsoft/microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "net-streetStyleCrew.dll" ]
由于 aspnetcore-build:2.0 带有一个太旧的 npm/node,它必须更新。它还没有进入 angular-cli 部分,但我认为当然也需要新鲜。 这是我现在遇到的问题,我不知道在尝试更新时如何解决容器内的网络问题:
Step 5/15 : RUN npm install npm@latest
---> Running in 72531196fc83
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "npm@latest"
npm ERR! node v6.13.0
npm ERR! npm v3.10.10
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request:
npm ERR! C:\app\npm-debug.log
The command 'cmd /S /C npm install npm@latest' returned a non-zero code: 1
我正在尝试在 Windows 容器上运行它,因为我也没有大量使用 Linux 的经验。
我也绝对愿意接受任何可以改进我对基本概念的处理方法的建议。提前致谢。
【问题讨论】:
标签: docker asp.net-core-2.0 asp.net-core-webapi angular-universal