gpt4 book ai didi

linux - FROM ... AS 命令在 Linux 中给出解析错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:50:40 25 4
gpt4 key购买 nike

.NET Core 文档的 Docker 示例的第一条语句为:

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env

此命令适用于 Windows 系统,但在 Linux 上会出现问题:

Step 1/10 : FROM mcr.microsoft.com/dotnet/core/sdk AS build-env
Error parsing reference: "mcr.microsoft.com/dotnet/core/sdk AS build-env" is not a valid repository/tag: invalid reference format

我尝试删除 AS <name>这有效,但现在有一个需要使用该名称的场景。

下面是基本示例的代码片段

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

最佳答案

我认为你应该先检查 docker 版本。多阶段构建是一个相对较新的功能:

documentation状态:

Multi-stage builds are a new feature requiring Docker 17.05 or higher on the daemon and client.

所以你应该升级 docker 版本...

关于linux - FROM ... AS 命令在 Linux 中给出解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58693737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com