VS 2017+ASP.NET Core+Docker: published dev image does not work

I created an ASP.NET core project with docker support. Good thing: it works. Bad thing: the “dev” image it creates does not really contain application code. The code is added to the container at run time using local volume mappings. if you inspect the image, you will find the “/app” directory empty, and there is nothing to run there. To create a usable image one needs to do “publish” in Visual Studio. This creates a “final” image that does contain the code, can be published to DockerHub and then run on a remote machine.

Visual Studio invokes a rather complex “docker run” command to create a “dev” container from the image. In my case it is

docker run -dt -v "C:\Users\ivan\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\ivan\dev\exp\dotnetcore\AspNetJekyll:/app" -v "C:\Users\ivan\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro" -v "C:\Users\ivan\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro" -v "C:\Users\ivan.nuget\packages\:/root/.nuget/fallbackpackages2" -v "C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "ASPNETCORE_ENVIRONMENT=Development" -e "ASPNETCORE_URLS=https://+:443;http://+:80" -e "ASPNETCORE_HTTPS_PORT=44355" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages2" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages;/root/.nuget/fallbackpackages2" -p 7159:80 -p 44355:443 --entrypoint tail aspnetjekyll:dev -f /dev/null

This command does not seem to appear in any of the project settigns, visible in the UI or in the project files. Frankly, I don’t like that level of magic, this is too opaque, and difficult to debug/change if something goes wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *