Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
387 stars 177 forks source link

[Issue] Test if docker is running before calling docker commands #393

Open jongio opened 2 years ago

jongio commented 2 years ago

azd up

Got this:

Error: Command Failed: deploying service jongtodo100api: packaging service jongtodo100api: building container image: jongtodo100api at src/api: building container image: exit status 1 : exit code: 1, stdout: , stderr: error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&platform=amd64&rm=1&shmsize=0&t=jongtodo100api&target=&ulimits=null&version=1": open //./pipe/docker_engine: The system cannot find the file specified.

Turns out docker wasn't running

I would like azd to tell me it isn't running before it tries to execute the command.

ellismg commented 2 years ago

We could consider making CheckInstalled() responsible for this. If we did that, we may want to change the ExternalTool interface slightly so that instead of having an InstallUrl() we return an error that would have some description of how to solve the problem. We could aggregate it with one of the mutli error packages.

jongio commented 2 years ago

CheckRunning() would make sense as an optional method.

savannahostrowski commented 8 months ago

This came up a bunch in our UXR for simplified init. We should investigate this as polish during Germanium

isaacrlevin commented 7 months ago

I am learning Go and wanted to take a look at a fully fledged app, so I came across this help-wanted issue. Looking at this it seems like the EnsureInstalled() function needs to be updated. The function checks to see if a tool is installed, and if it is, it passes the check. This won't work for Docker as it can be installed but not running. Here is the line in question that needs to be updated.

for _, tool := range tools {

for _, tool := range tools {
    _, ok := confirmedTools[tool.Name()]
    if ok {
    log.Printf("Skipping install check for '%s'. It was previously confirmed.", tool.Name())
    continue
}

Ideally there needs to be a check in this area to check if docker is running (maybe docker info). One thing that should be added to the ExternalTool interface to flag tools that need to be checked and that calls an alternate workflow (possibly an EnsureRunning() function)

isaacrlevin commented 7 months ago

@jongio what sample did you get this error with? I am not able to replicate using Dev Containers. Not sure if that is expected however