.NET Core Docker Container | C# Docker Console Application

preview_player
Показать описание
Today we are going to learn how to generate a docker image from you C# application.
Рекомендации по теме
Комментарии
Автор

Thanks very much for this. The DX for first-time docker use in VS and VS Code is truly awful. I was trying to build a solution with three projects, one dependent on the other two, and every built-in method failed, including this one, but it helped me to understand why. I'll start with a single project and build from there.

davak
Автор

Finally found the issue! Unless your project is on the root level, the auto-generated docker file ALWAYS HAS THE WRONG PATHS... Fixable, but annoying. Also, any additional projects in the solution are not copied or built by the Dockerfile, even if the project you are building depends on them! (The last part is only the case in the VS Code extension. Visual studio includes copy steps for dependencies, thankfully).

After messing with the paths in the Dockerfile, I realized the best fix is to simply move the Dockerfile up one level into the solution directory from File Explorer or the command prompt. Then, you can docker build . -t imagename from the solution directory.

If you still want to see the Dockerfile in your VS solution, you can right click on the solution, then Add -> Existing Item... and select the Dockerfile!

davak