Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve docker context 'desktop-linux' with VisualStudio 2022 and Docker Desktop v4.34.0 #14295

Open
Aloysius999 opened this issue Sep 4, 2024 · 6 comments

Comments

@Aloysius999
Copy link

Aloysius999 commented Sep 4, 2024

Description

In an attempt to resolve this problem, I have looked at similar issues to this from 3 years ago - it looks to me like the issuer persists.

In VisualStudio 2022 I create a simple ASP.Next Core API appl - it uses the default demo API generated by VS.

With Desktop Docker v4.34.0 installed it will run fine in a docker container locally.

When I try to publish from VS I see Failed to initialize: unable to resolve docker endpoint: context "desktop-linux": context not found: open

I have tried switching the context in Docker Desktop but still produced this error.

Reproduce

Run the Publish feature in VS 2022

Publish has encountered an error.
Running the docker.exe tag command failed.

Failed to initialize: unable to resolve docker endpoint: context "desktop-linux": context not found: open C:\Users\Steve\AppData\Local\Temp\fc5d16aedb0242049848dc7e5c4f9e60\contexts\meta\fe9c6bd7a66301f49ca9b6a70b217107cd1284598bfc254700c989b916da791e\meta.json: The system cannot find the path specified.

A diagnostic log has been written to the following location:
"C:\Users\Steve\AppData\Local\Temp\tmp6995.tmp"

Expected behavior

No response

docker version

Client:
 Version:           27.2.0
 API version:       1.47
 Go version:        go1.21.13
 Git commit:        3ab4256
 Built:             Tue Aug 27 14:17:17 2024
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.34.0 (165256)
 Engine:
  Version:          27.2.0
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       3ab5c7d
  Built:            Tue Aug 27 14:15:15 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.20
  GitCommit:        8fc6bcff51318944179630522a095cc9dbf9f353
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    27.2.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.16.2-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.2-desktop.2
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.34
    Path:     C:\Program Files\Docker\cli-plugins\docker-debug.exe
  desktop: Docker Desktop commands (Alpha) (Docker Inc.)
    Version:  v0.0.15
    Path:     C:\Program Files\Docker\cli-plugins\docker-desktop.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.25
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.5
    Path:     C:\Program Files\Docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.3.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.13.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 29
 Server Version: 27.2.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.153.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 14.56GiB
 Name: docker-desktop
 ID: d0573ac6-1fd7-43c0-ba79-80d9e7e097ff
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=npipe://\\.\pipe\docker_cli
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile

Diagnostics ID

1212

Additional Info

No response

@Aloysius999 Aloysius999 changed the title Unable to resolve docker context 'desktop-linux' with VisualStdion 2022 and Docker Desktop v4.34.0 Unable to resolve docker context 'desktop-linux' with VisualStudio 2022 and Docker Desktop v4.34.0 Sep 4, 2024
@hectorm-bmg
Copy link

We are getting the same error here ... It first manifested in our jenkins pipeline but confirmed it also happens in Visual Studio 2022.

@hectorm-bmg
Copy link

We are not getting this error anymore ... not sure why.
For our jenkins pipeline we changed from docker.withRegistry to regular docker login and docker push commands using a service principal in azure and now we are successfully deploying again.

@thaJeztah
Copy link
Member

thaJeztah commented Sep 11, 2024

Based on the location it's trying to look for the context;

Failed to initialize: unable to resolve docker endpoint: context "desktop-linux": context not found: open C:\Users\Steve\AppData\Local\Temp\fc5d16aedb0242049848dc7e5c4f9e60\contexts\meta\fe9c6bd7a66301f49ca9b6a70b217107cd1284598bfc254700c989b916da791e\meta.json: The system cannot find the path specified.

I suspect this is an issue with Visual Studio's Docker integration.

ISTR that the Visual Studio integration did some trickery to patch the CLI config with some additional options; basically this was something like;

  • copy the user's CLI config file (~/.docker/config.json) to a temporary directory
  • modify the file
  • run the docker CLI, using the temporary directory as configuration directory (docker --config=/path/to/temp-directory ...)

The CLI configuration will contain the name of the currently selected docker context ("desktop-linux" in this case), which is kept in the copy of the config file.
However, the docker context itself is stored inside the CLI configuration directory; if the CLI is set to use a different directory for the configuration, it will look inside that location; the temporary directory created by Visual Studio likely doesn't have a copy of those files, so that now fails.

ISTR Visual Studio had to set some custom headers (for which they had to create the copy), and for which I added an alternative; docker/cli#5098 but I don't think they're using that currently.

The other alternative is to override the context to be "default" (which can be done through an DOCKER_CONTEXT environment variable), in which case it won't try to find the "desktop-linux" context.

ISTR they were considering (or have implement) that last option, but not sure what release of Visual Studio that was included in.

@jcrosspuma
Copy link

Thank you for looking into this. I am facing the exact same issue when publishing docker images from Visual Studio.

@iadaz
Copy link

iadaz commented Sep 23, 2024

Updating Docker Desktop to 4.34.2 and Visual Studio to 17.11.4 got me around this issue.

@jcrosspuma
Copy link

Thanks! Updating Visual Studio worked for me as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
@thaJeztah @iadaz @Aloysius999 @bsousaa @hectorm-bmg @jcrosspuma and others