-1

我正在写码头集装箱。我站起来了,但在我看来,它不起作用。我想运行 dotnet 应用程序,它使用 rabbitmq 进行通信。运行命令后:'docker-compose logs mlmodule' 它不显示任何日志(但它应该)。我认为这是由错误的图像代码引起的。我是 docker 和 docker-compose 的新手。

这是图像的代码

#docker base SDK image
FROM mcr.microsoft.com/dotnet/sdk:5.0 as build-env
WORKDIR mlmodule
#copy the CSPROJ file and restore any dependecies
COPY mlmodule/*.csproj ./
RUN dotnet restore
#copy project files and build release
COPY / ./
RUN dotnet publish mlmodule.sln -c Release -o out
#Generate runtime image
FROM mcr.microsoft.com/dotnet/runtime:5.0.9-alpine3.13-amd64
WORKDIR mlmodule
COPY --from=build-env mlmodule/out .

这就是 docker-compose 的代码:

rabbitmq:
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
ports:
  - 5672:5672
  - 15672:15672
volumes:
  - ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/
  - ~/.docker-conf/rabbitmq/data/:/var/log/rabbitmq/
networks:
  - rabbitmq_go_net


ml-module:
build: ./mlmodule/
container_name: ml-module
environment:
  CLOUDSDK_PYTHON: /usr/bin/python3
  LD_LIBRARY_PATH: /usr/local/lib
depends_on:
  - rabbitmq
tty: true
networks:
  - rabbitmq_go_net

编辑:

我很可能修复了 rabbitmq 容器,现在我看到了日志:

 ml-module    | Could not execute because the specified command or file was not found.
 ml-module    | Possible reasons for this include:
 ml-module    |   * You misspelled a built-in dotnet command.
 ml-module    |   * You intended to execute a .NET program, but dotnet-MLModule.sln does not exist.
 ml-module    |   * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
4

1 回答 1

0

解决办法是在dockerfile中加入这一行,配置错误。目前 dotnet sdt 没有 dotnet-ef commang:

 RUN dotnet tool install -g dotnet-ef --version 5.0

我不得不将它手动放入 dockerfile 中。帮助文章链接:

在 .NET Core 3 中找不到命令 dotnet ef

于 2021-09-15T10:08:01.893 回答