启动时出现Dotnetcore容器错误,询问我是否要运行SDK命令 [英] Dotnetcore container errors on startup asking if I mean to run SDK commands

查看:380
本文介绍了启动时出现Dotnetcore容器错误,询问我是否要运行SDK命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的dotnetcore 2.0应用程序,并且希望将其容器化。这个容器的想法是在部署时运行一次,以完成一些应用程序配置任务。



目前,代码只是这样做了……

 类程序
{
static void Main(string [] args)
{
Console.WriteLine( 你好,世界!);
}
}

docker文件看起来像这样……

 从Microsoft / dotnet:2.0运行时
ARG源
WORKDIR / app
COPY $ {来源:-obj / Docker / publish}。
ENTRYPOINT [ dotnet, consoleapp.dll]

我在Visual中按F5在Studio 2017中,我可以通过执行 docker image ls 命令来查看容器是否存在。



然后我尝试如下运行容器:



docker运行consoleapp:dev



我现在收到错误:

 您是要运行dotnet SDK命令吗?请从以下位置安装dotnet SDK:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

我的想法是,因为我使用运行时映像作为映像的基础,所以我应该能够以某种方式启动我的应用程序。我猜这里的错误是 dotnet 构成我的入口点的一部分是dotnet SDK的一部分,因此不在我的基本映像中。



该容器是否应基于dotnet核心的非运行时版本?

解决方案

您看到此错误消息的原因之一是当传递给 dotnet 的参数未知时。



code>运行时无法识别您要传递给它的参数,并且想知道是否应该使用 sdk 。 / p>

确保dll的名称及其路径在以下位置正确:

  ENTRYPOINT [ dotnet, consoleapp.dll] 

另外,请确保 COPY 指令按预期工作。



在您的示例中,它是从 obj / Docker / publish 文件夹。准备执行的输出应该从 bin 文件夹输出。
如果您使用的是发布版本,请确保在创建容器之前运行 dotnet publish 。或在创建映像时还原/构建/发布。



请记住,dll必须完全以 WORKDIR 。在您的情况下:/ app
除非您提供 dotnet



的路径,否则我已经创建了一个 Github上的基本工作示例


I'm creating a simple dotnetcore 2.0 application and I want to containerize it. The idea being this container will run once on deployment to do some application configuration tasks.

At present, the code just does this...

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
    }
}

The docker file looks like this...

FROM microsoft/dotnet:2.0-runtime
ARG source
WORKDIR /app
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "consoleapp.dll"]

I hit F5 in Visual Studio 2017 and I can see by doing a docker image ls command that the container exists.

I then attempt to run the container as follows:

docker run consoleapp: dev

I now get the error:

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

My thinking on this is that because I am using a runtime image to base my image on, I should be able to somehow start my application. I'm guessing the error here is that dotnet which forms part of my entry point is part of the dotnet SDK and hence is not in my base image.

Should I base this container on a non-runtime version of the dotnet core?

解决方案

One reason why you can see this error message is when the argument passed to dotnet is unknown.

The runtime doesn't recognize the argument you are passing to it and wonder if you perhaps should be using the sdk instead.

Make sure the name of the dll and the path to it are correct in:

ENTRYPOINT ["dotnet", "consoleapp.dll"]

Also, make sure the COPY instruction works as expected.

In your example it's picking files from the obj/Docker/publish folder. The output ready to be executed should come out of the bin folder instead. If you are using the published version, make sure to run dotnet publish before creating the container. Or restore/build/publish when creating the image.

Remember the dll would have to end up exactly at the WORKDIR. In your case: /app Unless you provide the path to dotnet

I've created a basic working sample on Github:

这篇关于启动时出现Dotnetcore容器错误,询问我是否要运行SDK命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆