containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.73k stars 2.41k forks source link

Getting socket path on Windows does not work #19918

Open hansmbakker opened 1 year ago

hansmbakker commented 1 year ago

Issue Description

This documentation page says to run podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}' to get the socket path.

However, that results in:

Error: template: inspect:1:29: executing "inspect" at <.ConnectionInfo.PodmanSocket.Path>: nil pointer evaluating *machine.VMFile.Path

Just running podman machine inspect shows (I trimmed the output to the relevant ConnectionInfo section:

"ConnectionInfo": {
    "PodmanSocket": null,
    "PodmanPipe": {
         "Path": "\\\\.\\pipe\\podman-machine-default"
     }
}

Steps to reproduce the issue

Steps to reproduce the issue

  1. Open Powershell on Windows 11
  2. Install podman using winget - winget install RedHat.Podman
  3. Install podman desktop using winget - winget install RedHat.Podman-Desktop
  4. Initialize & start podman using podman desktop
  5. Optionally run podman run quay.io/podman/hello to verify podman works
  6. Run podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}'

Describe the results you received

Error: template: inspect:1:29: executing "inspect" at <.ConnectionInfo.PodmanSocket.Path>: nil pointer evaluating *machine.VMFile.Path

Describe the results you expected

A socket path

podman info output

If you are unable to run podman info for any reason, please provide the podman version, operating system and its version and the architecture you are running.

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

Windows desktop (Windows 11 build 22621.2215)

Additional information

No response

arixmkii commented 1 year ago

You can use podman machine inspect --format '{{.ConnectionInfo.PodmanPipe.Path}}'

ConnectionInfo.PodmanSocket.Path is reserved for QEMU and other providers and uses UNIX sockets on supported OS (including Windows), but for using named pipe there is a separate property, because it is different transport protocol.

Background, this decision was introduced, because while Podman machine could optionally support both types, but the Podman Desktop on Windows can operate only with named pipe due to libuv limitations. So, for machine providers, which support real socket they would also need to support named pipe for Podman Desktop compatibility.

arixmkii commented 1 year ago

The documentation in Podman Desktop is wrong. Code part responsible for retrieving path of the pipe https://github.com/containers/podman-desktop/blob/4eca4d670efbdcbaea9443f25833eff08a572bb5/extensions/podman/src/extension.ts#L161

hansmbakker commented 1 year ago

The documentation in Podman Desktop is wrong. Code part responsible for retrieving path of the pipe https://github.com/containers/podman-desktop/blob/4eca4d670efbdcbaea9443f25833eff08a572bb5/extensions/podman/src/extension.ts#L161

Ok, then I get the pipe but not the socket - will that allow me to set the DOCKER_HOST env var in such a way that it allows for transparent migration from Docker? (and use the VS Code Docker extension, which relies on that env var)

arixmkii commented 1 year ago

@hansmbakker It should work as Docker API on Windows was exposed via named pipe last time I checked it.

hansmbakker commented 1 year ago

Will try that, thank you!

hansmbakker commented 1 year ago

Ok - I tried setting the DOCKER_HOST env var to \\.\pipe\podman-machine-default and I set the path to the docker executable to podman but the extension keeps saying it failed to connect. Does anybody have a suggestion?

Besides this extension, podman works fine for the DevContainers extension using podman as a value for the path to the docker executable. The DevContainers extension does not rely on the DOCKER_HOST environment variable.

image
foxydevloper commented 1 year ago

Here's a fix for the documentation: https://github.com/containers/podman-desktop/pull/4157 image You need to prefix the pipe with npipe:// when putting it in the DOCKER_HOST environment variable. Also note, you don't actually need to change the DOCKER_HOST at all if you're on windows. Podman also listens on the docker_engine named pipe that most tools should default to using.https://github.com/containers/podman/blob/cc8c28eb7c0c336931b9bf5879ff454818519c94/docs/tutorials/podman-for-windows.md?plain=1#L109-L111

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

hansmbakker commented 1 year ago

Thank you for the suggested fixes! I tried setting DOCKER_HOST to npipe:////./pipe/docker_engine but unfortunately it did not help. The UI says

Failed to connect. Is Docker running? Error: Invalid image JSON

TheDocker output window stays empty (no logging or stack traces), and other output windows do not mention anything either.

My environment:

image
marmotae commented 11 months ago

Is this still unresolved? im pretty much in the same situation, Cant connect to the npipe from vs code on windows

Zak-Ghani commented 11 months ago

Seeing same issue on my environment OS: Win10 VS Code: 1.84.2 Podman: 4.8.1

Have tried all the fixes set out above but still seeing the "Failed to connect. Is Docker installed?" message. As with everyone else here mentioning the issue I too am in the process of moving from Docker to Podman

dbiegunski commented 11 months ago

Same issue over here ... trying to replace docker with podman but cannot connect VS Code to Podman..

Stan-RED commented 11 months ago

The same problem. with VS Code.

arixmkii commented 11 months ago

@StanEgo @dbiegunski @Zak-Ghani @hansmbakker This extension is known to have issues with Podman. Could you test with the extension version downgraded to 1.22.x as workaround? I checked in a test clean system and it worked with 1.22.2

Here is related ticket https://github.com/containers/podman/issues/17306 And there are numerous tickets in bug tracker of the extension. I'm not a representative of either MS or Podman development team, so, I can't say who should be responsible to fix this.

ShyamBhattacharyya commented 2 months ago

Currently there is two options available to use podman containers within VS Code.

  1. Use Docker extention version 1.22.2 or below. From version 1.23.0+, the extention has switched from HTTP API based communication with the deamon to CLI based which is creating an compatibility issue between the podman & docker with the command returned keys. For example Id vs ID
    image

  2. Use Pod Manager. A new extention has created by @dreamcatcher45. It is working fine with podman containers. [https://marketplace.visualstudio.com/items?itemName=dreamcatcher45.podmanager&ssr=false#overview](https://github.com/containers/podman/issues/url) image