Muhammad Zunair
Muhammad Zunair

Reputation: 575

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

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.

Upvotes: 33

Views: 51789

Answers (7)

CDaniil
CDaniil

Reputation: 1

For me it worked after doing two things: -removing reference to Microsoft.VisualStudio.Azure.Containers.Tools.Targets -adding this in docker-compose.override.yml

version: '3.4'

services: your_service_name_here: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=https://+:443;http://+:80 ports: - "80" - "443" volumes: - ~/.aspnet/https:/root/.aspnet/https:ro - ~/.microsoft/usersecrets:/root/.microsoft/usersecrets:ro

Upvotes: 0

Scott
Scott

Reputation: 171

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

Removing the reference fixed the error.

Upvotes: 17

Sibeesh Venu
Sibeesh Venu

Reputation: 21749

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.

Upvotes: 1

Radiofisik
Radiofisik

Reputation: 150

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)

Upvotes: 0

user890255
user890255

Reputation: 478

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.

Upvotes: 1

jagdish gussai
jagdish gussai

Reputation: 75

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

Upvotes: -4

Muhammad Zunair
Muhammad Zunair

Reputation: 575

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.

Upvotes: 14

Related Questions