我有事。我的带有响应模板webapp的aspnet core 2.1的dockerfile。我的aspnet核心SDK是2.1.301。但是构建总是失败。错误消息位于下面
FROM microsoft/dotnet:2.1.1-aspnetcore-runtime-alpine3.7 AS base
WORKDIR /app
FROM microsoft/dotnet:2.1.301-sdk-alpine3.7 AS build
# set up node
ENV NODE_VERSION 10.5.0
ENV NODE_DOWNLOAD_SHA 5d77d2c68c06404028f063dca0947315570ff5e52e46f67f93ef9f6cdcb1b4a8
RUN curl -SL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz" --output nodejs.tar.gz \
&& echo "$NODE_DOWNLOAD_SHA nodejs.tar.gz" | sha256sum -c - \
&& tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 \
&& rm nodejs.tar.gz \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
WORKDIR /src
COPY webapp.csproj .
RUN dotnet restore webapp.csproj
COPY . .
RUN dotnet build webapp.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish webapp.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "webapp.dll"]
这是日志
Sending build context to Docker daemon 69.63MB
Step 1/17 : FROM microsoft/dotnet:2.1.1-aspnetcore-runtime-alpine3.7 AS base
---> a50663099cc8
Step 2/17 : WORKDIR /app
---> Using cache
---> eb9a35d94f33
Step 3/17 : FROM microsoft/dotnet:2.1.301-sdk-alpine3.7 AS build
---> d5accd0a6f97
Step 4/17 : ENV NODE_VERSION 10.5.0
---> Running in e7797f27733e
Removing intermediate container e7797f27733e
---> c1b611e0b1eb
Step 5/17 : ENV NODE_DOWNLOAD_SHA
5d77d2c68c06404028f063dca0947315570ff5e52e46f67f93ef9f6cdcb1b4a8
---> Running in 07ee74558e7a
Removing intermediate container 07ee74558e7a
---> 3d0a2d6f2a9f
Step 6/17 : RUN curl -SL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz" --output nodejs.tar.gz && echo "$NODE_DOWNLOAD_SHA nodejs.tar.gz" | sha256sum -c - && tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 && rm nodejs.tar.gz && ln -s /usr/local/bin/node /usr/local/bin/nodejs
---> Running in c72c1e9a3593
/bin/sh: curl: not found
The command '/bin/sh -c curl -SL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz" --output nodejs.tar.gz && echo "$NODE_DOWNLOAD_SHA nodejs.tar.gz" | sha256sum -c - && tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 && rm nodejs.tar.gz && ln -s /usr/local/bin/node /usr/local/bin/nodejs' returned a non-zero code: 127
我从Docker for Visual Studio的输出中基于上面的Dockerfile,然后删除了docker compose项目,并将Dockerfile从父文件夹(与.sln一起)移至项目本身(与.csproj一起)
我相信该模板在Startup.cs中包含CRA构建,因此它需要Node(npm)
答案 0 :(得分:0)
对不起。我现在开始工作了,我只需要使用microsoft / dotnet:2.1.301-sdk而不是Alpine进行构建。然后就没事了