29

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.

Dumi
  • 1,414
  • 4
  • 21
  • 41
Muhammad Zunair
  • 535
  • 1
  • 5
  • 12

6 Answers6

16

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

Removing the reference fixed the error.

Scott
  • 161
  • 1
  • 4
14

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.

Muhammad Zunair
  • 535
  • 1
  • 5
  • 12
1

In my case, this issue was caused by a disabled BIOS Virtualization. To enable Virtualization, see here. In order to check whether Virtualization is already enabled, start Task Manager > Performance > find Virtualization. If you are hosting your docker container application in full feature IIS, make sure you start Visual Studio as an Administrator.

user890255
  • 458
  • 5
  • 9
1

I was getting the same error when I was trying to rebuild my solution after changing my .Net Core 2.0 application to .Net Core 2.2. As I reset my windows, there was no docker installed on my machine. To fix this all I had to do is to install the docker for desktop as I wanted to containerize my applications.

Once you install the Docker, it will ask you to enable Hyper-V and Container features. By clicking the Ok button in the pop up as preceding, will enable this features for you.

enter image description here

Your computer will be restarted automatically and once it is done, you should be able to see that the Virtualization is enabled in the task bar.

enter image description here

After this I was not facing this error.

Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140
0

Check shared folders inside the default virtual machine setting in Virtual box to make sure you shared the disk where you project located. By default shared only C:\Users. So alternatively you can move your project somewhere inside C:\Users folder (for example in Desktop folder)

Radiofisik
  • 150
  • 11
-5

I was facing the same issue and I resolved it by switching to IIS Express instead of Docker in debug menue on visual studio 2017

enter image description here

Anastasios Selmani
  • 3,579
  • 3
  • 32
  • 48
  • 5
    When we switch to IIS Express in visual studio, the application runs on local IIS Express rather than docker. It is similar to run any other .NET application. As this application is not containerized, so containerization goal is not achieved. You can verify this by running **docker ps** command in power shell which shows the running containers on your system. – Muhammad Zunair Feb 17 '19 at 20:25
  • 3
    downvote, op asked how to debug a container service and your answer is basically, "Stop trying and use IIS express instead" – P. Roe Jun 21 '19 at 16:11
  • upvote because your answer reminded me to check that option – cikatomo Jun 05 '23 at 02:34