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

28,952

Solution 1

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.

Solution 2

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

Removing the reference fixed the error.

Solution 3

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.

Solution 4

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.

Share:
28,952
Muhammad Zunair
Author by

Muhammad Zunair

Updated on July 09, 2022

Comments

  • Muhammad Zunair
    Muhammad Zunair almost 2 years

    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.

  • Muhammad Zunair
    Muhammad Zunair about 5 years
    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.
  • P. Roe
    P. Roe almost 5 years
    downvote, op asked how to debug a container service and your answer is basically, "Stop trying and use IIS express instead"
  • Çağlar Can Sarıkaya
    Çağlar Can Sarıkaya over 2 years
    when I delete this it threw "the project doesn't know how to run the profile docker" and this error drive me to start :D
  • vivek nuna
    vivek nuna over 2 years
    @ÇağlarCanSarıkaya I have also got the same error, is there any workaround to solve this ?
  • Çağlar Can Sarıkaya
    Çağlar Can Sarıkaya over 2 years
    hi, I solved it by installing docker desktop. When I need to work on containers firstly start docker desktop, then secondly the project on visual studio. Actually it is not look like a proper solition but worked for me
  • Alejandro Galera
    Alejandro Galera over 2 years
    I'm trying to do it without installing Docker for Windows; just docker in wsl. Do you know how to do it? Thanks
  • Alejandro Galera
    Alejandro Galera over 2 years
    Is it possible to do it without installing docker desktop? I'd like to solve it directly with docker in wsl
  • Moslem Hadi
    Moslem Hadi about 2 years
    *NOTE: You also have to delete "Docker" prop from "Properties/launchSettings.json"