【发布时间】:2022-08-14 17:33:05
【问题描述】:
我目前正在使用 .net6 构建一个 API 示例,并且我正在跟踪使用 docker 来运行 API。
我的 docker 文件如下所示:
# Grab the app package and create a new build
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
# Let\'s add all the files into the app directory
WORKDIR /app
# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT [\"dotnet\", \"DotNet.Docker.dll\"]
我通过运行以下命令创建了图像:
docker build -t binarythistle/dockerapi .
现在,我正在尝试运行图像来创建容器:
docker run -p 8000:80 dockerapi
但是,我得到以下结果:
The command could not be loaded, possibly because:
* You intended to execute a .NET application:
The application \'DotNet.Docker.dll\' does not exist.
* You intended to execute a .NET SDK command:
No .NET SDKs were found.
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
有谁知道可以做些什么来解决这个问题?
站点注释:我按照推荐下载了 .NET6.0 SDK macOS,但我仍然遇到问题。我正在使用 .net 运行的项目是一个标准 api 项目,其中允许我创建它的命令如下:
dotnet new webapi -n DockerAPI
标签: c# .net docker .net-core dockerfile