Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Container Tools requires Docker to be running before building, debugging or running a containerized project

Tags:

I am working on .Net core Microservices. I installed Docker Toolbox containing docker cli and kitematics. After that i created a simple (.Net core) web api project in visual studio 2017 and also enable docker support.

But when i hit F5 to run the program it shows following error and doesn't run.

Visual Studio Container Tools requires Docker to be running before building, debugging or running a containerized project.

Please review the attached image.

Visual studio error on running the project enter image description here

If i build and run the project using docker cli, it's working. The problem is with visual studio 2017.

like image 448
Muhammad Zunair Avatar asked Jan 30 '18 15:01

Muhammad Zunair


2 Answers

In my case I had an erroneous reference in Dependencies > Packages to Microsoft.VisualStudio.Azure.Containers.Tools.Targets

Removing the reference fixed the error.

like image 143
Scott Avatar answered Sep 18 '22 19:09

Scott


The problem occurs because Visual studio container is unable to connect to docker for windows and solution for this is to open the visual studio 2017 from Docker CLI using following command. /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/Community/Common7/IDE/devenv.exe C:\\PATH\\TO\\MY\\SOLUTION.sln

Here:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe

is the location of my devenv.exe file and 2nd parameter

C:\\PATH\\TO\\MY\\SOLUTION.sln

shows the path of solution file.

For further details of this solution, click Here.

like image 34
Muhammad Zunair Avatar answered Sep 19 '22 19:09

Muhammad Zunair