如何从命令行构建由visual studio 2019创建的dockerfile?

4uqofj5v  于 2022-11-28  发布在  Docker
关注(0)|答案(2)|浏览(165)

我有由Visual Studio 2019创建的dockerfile。我如何手动运行它?下面是dockerfile:

FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-nanoserver-1903 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:2.1-nanoserver-1903 AS build
WORKDIR /src
COPY ["Client/Client.csproj", "Client/"]
RUN dotnet restore "Client/Client.csproj"
COPY . .
WORKDIR "/src/Client"
RUN dotnet build "Client.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Client.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Client.dll"]
de90aj5v

de90aj5v1#

在dockerfile所在的文件夹中打开终端并执行:

docker build -t image_name .

成功生成后,执行:

docker run -d image_name

我建议您阅读docker builddocker run命令的官方文档。您可以找到可能对您的情况有用的其他标志。

ryhaxcpt

ryhaxcpt2#

精确定位到停靠文件所在的项目文件夹(而不是解决方案)。
在终端中运行以下命令:

docker build -f Dockerfile ..

船坞建造

相关问题