I'm currently trying to launch a Docker component with a ASP.NET Core application.
I use the following repo for my test : https://github.com/aspnet/cli-samples
I ran the following commande without any issue :
git clone https://github.com/aspnet/cli-samples aspnet-Home
COPY . .
ENTRYPOINT ["dotnet", "helloweb.dll"]
sudo docker build –t helloweb .
sudo docker run -d helloweb
sudo docker images
sudo docker ps
The error you highlighted is because
helloweb.dll you set as the
ENTRYPOINT doesn't exist. There could be two reasons for it
In this case you should run
dotnet restore from the project home directory, then navigate to
HelloWeb directory and run
dotnet publish. When I run this command, I see the following:
publish: Published to /code/HelloWeb/bin/Debug/netcoreapp1.0/publish Published 1/1 projects successfully
ENTRYPOINTpath is wrong
COPY . . directive will copy everything from the current directory into your
app directory. That means
HelloWeb.dll will actually be in
bin/Release/... for release builds).
Option 1: Modify your entrypoint with the full path
ENTRYPOINT ["dotnet", "bin/Debug/netcoreapp1.0/publish/HelloWeb.dll"]
Your application should happily start and serve requests.
Option 2: Modify your
Once your project has been published, everything you'll need to run it will be in the
publish directory. You could copy the contents of that into the
/app directory and your entrypoint will be correct. That would look like this
FROM microsoft/aspnetcore WORKDIR /app COPY ./bin/Debug/netcoreapp1.0/publish/ . EXPOSE 80 ENTRYPOINT ["dotnet", "HelloWeb.dll"]
You will also probably want to add the
EXPOSE directive to tell Docker that your container will be listening on port 80.
When that succeeds, you should see (if you run in interactive mode)
docker run -it helloweb Hosting environment: Production Content root path: /app Now listening on: http://+:80 Application started. Press Ctrl+C to shut down.
You could also use the
microsoft/dotnet:latest image instead. That image comes with the SDK installed and a very convenient
run command. The Dockerfile would look like this
FROM microsoft/dotnet:latest COPY . /app WORKDIR /app RUN dotnet restore ENV ASPNETCORE_URLS http://*:5000 EXPOSE 5000 ENTRYPOINT ["dotnet", "run"]
and you should be able to modify your source and build and run your container.