When using Visual Studio 2017 and trying to create a Docker image for your ASP.NET web app from the standard microsoft\aspnet image (or another image), you may have the following error message : GetFileAttributesEx bin\Release\PublishOutput : The system cannot find the path specified
This error is caused by the .dockerignore file generated by Visual Studio 2017 (more information on .dockerignore file : https://docs.docker.com/engine/reference/builder/#dockerignore-file).
How to solve the issue
- Open and edit the .dockerignore file located at the root of your Visual Studio project
- Remove the first line with the ‘*’ (this is the guilty line !)
- Save the modified .dockerignore file
- Re execute your docker build command (ex : docker build –t <your tag> .)
Original Visual Studio 2017 .dockerignore file :
The corrected .dockerignore file :
Check your web app to know if everything works fine
- First, you won’t be able to use the URL http://localhost, you need the IP address of the container. To find it, execute this command in Powershell :
- Open your favorite browser and enter the URL http//<your ip address> to show you web app shining
docker inspect -f « {{ .NetworkSettings.Networks.nat.IPAddress }} » ncit_liasse
More documentation on the use of this image at https://hub.docker.com/r/microsoft/aspnet/
Useful documentation on how to migrate an ASP.NET MVC application to Docker : https://docs.microsoft.com/en-us/aspnet/mvc/overview/deployment/docker-aspnetmvc
Now enjoy migrating your ASP.NET MVC web apps to Docker containers !