Docker ASP.NET MVC image creation issue ‘GetFileAttributesEx : The system cannot find the path specified’

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

image

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

  1. Open and edit the .dockerignore file located at the root of your Visual Studio project
  2. Remove the first line with the ‘*’ (this is the guilty line !)
  3. Save the modified .dockerignore file
  4. Re execute your docker build command (ex : docker build –t <your tag> .)

Original Visual Studio 2017 .dockerignore file :

image

The corrected .dockerignore file :

image

Check your web app to know if everything works fine

  1. 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 :
  2. docker inspect -f « {{ .NetworkSettings.Networks.nat.IPAddress }} » ncit_liasse

  3. Open your favorite browser and enter the URL http//<your ip address> to show you web app shining

image

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 !