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 thesdk
instead.Make sure the name of the dll and the path to it are correct in:
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 thebin
folder instead. If you are using the published version, make sure to rundotnet 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 todotnet
I've created a basic working sample on Github:
Create an app:
Dockerfile: