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

On a Mac, the extension keeps timing out when using Podman instead of Docker #3367

Closed
benatshippabo opened this issue Jan 5, 2022 · 21 comments

Comments

@benatshippabo
Copy link

benatshippabo commented Jan 5, 2022

Steps to reproduce

# based on this blog post https://www.redhat.com/sysadmin/podman-mac-machine-architecture
brew install podman
pip3 install podman-compose
podman machine init
podman machine start

# to get the ssh path
podman system connection ls

Then set the vscode config to use Podman:

{
  "docker.dockerPath": "podman",
  "docker.host": "ssh://core@localhost:50261"
}

Afterwards, go to the Docker extension and see the following:
image

Expected outcome

After configuring the Docker extension, the user should see the list of created containers.

Context

cross posted here as well containers/podman#12745 (comment)

@bwateratmsft
Copy link
Collaborator

@benatshippabo do you have an SSH agent set up? Our explorer uses the dockerode NPM package, which in turn uses ssh2, which unfortunately requires an SSH agent--it is not able to pick up anything from ~/.ssh, unlike the Docker CLI (and presumably the Podman CLI too). I've noticed in the past that ssh2 throws a timeout error when it tries and fails to connect to an SSH agent.

More info about setting up an SSH agent here: https://code.visualstudio.com/docs/containers/ssh

@benatshippabo
Copy link
Author

@benatshippabo do you have an SSH agent set up? Our explorer uses the dockerode NPM package, which in turn uses ssh2, which unfortunately requires an SSH agent--it is not able to pick up anything from ~/.ssh, unlike the Docker CLI (and presumably the Podman CLI too). I've noticed in the past that ssh2 throws a timeout error when it tries and fails to connect to an SSH agent.

More info about setting up an SSH agent here: https://code.visualstudio.com/docs/containers/ssh

@bwateratmsft Thanks for the swift reply, I think we are getting somewhere. After adding the ssh private key using:

ssh-add ~/.ssh/podman-machine-default

The error message has now progressed to:
image

@bwateratmsft
Copy link
Collaborator

That looks promising! Is a value present in VSCode for environment variable SSH_AUTH_SOCK?

@benatshippabo
Copy link
Author

benatshippabo commented Jan 6, 2022

That looks promising! Is a value present in VSCode for environment variable SSH_AUTH_SOCK?

@bwateratmsft yep, it is set to:

❯ echo $SSH_AUTH_SOCK
/private/tmp/com.apple.launchd.KLlERFdN3t/Listeners

edit: I just tried setting the docker.dockerodeOptions instead of docker.host:

{
  "docker.dockerodeOptions": {
    "socketPath": "ssh://core@localhost:50685/run/user/1000/podman/podman.sock"
  }
}

And now it looks like it is connecting now 🎉
image

But there is an error, I don't think Podman supports the context command:

❯ podman context ls --format="{{json .}}"
Error: unknown flag: --format
❯ podman context ls
Error: unrecognized command `podman context`
Try 'podman --help' for more information.
❯ podman context
Error: unrecognized command `podman context`
Try 'podman --help' for more information.

@bwateratmsft
Copy link
Collaborator

Can you try that value of dockerodeOptions' socketPath as docker.host? I wonder if that works.

@benatshippabo
Copy link
Author

Can you try that value of dockerodeOptions' socketPath as docker.host? I wonder if that works.

It leads to the same socket hang up error, maybe it's how the socket path is concatenated?

@bwateratmsft
Copy link
Collaborator

Hmm...I wonder if the SSH is actually necessary. Does unix:///run/user/1000/podman/podman.sock work for docker.host?

@benatshippabo
Copy link
Author

benatshippabo commented Jan 6, 2022

unix:///run/user/1000/podman/podman.sock

That would be a negative. My understanding is that on a Mac, Podman creates a linux vm to run the containers on and their cli currently interacts through ssh only. Although it seems like they are working on it.

Btw, I added a comment here so we can figure out how to resolve the context command not being available.

@bwateratmsft
Copy link
Collaborator

Rats. Seems like this is yet one more thing that would be solved by #3263. I'll mark this as investigate but it may be pretty similar/the same as #3241, and also maybe just solved by #3263.

@bwateratmsft
Copy link
Collaborator

I had another thought, what happens if you set all of the following settings?

  "docker.dockerPath": "podman",
  "docker.host": "ssh://core@localhost:50261"
  "docker.dockerodeOptions": {
    "socketPath": "ssh://core@localhost:50685/run/user/1000/podman/podman.sock"
  }

I don't know for sure without trying it, but I think it might cause the logic that is running podman context ls ... to be skipped.

@benatshippabo
Copy link
Author

I had another thought, what happens if you set all of the following settings?

I don't know for sure without trying it, but I think it might cause the logic that is running podman context ls ... to be skipped.

Hmm, that gave a message we haven't seen yet:
image

@bwateratmsft
Copy link
Collaborator

Is that port of 50685 still accurate? Do both docker.host and docker.dockerodeOptions have the current port?

@benatshippabo
Copy link
Author

Is that port of 50685 still accurate? Do both docker.host and docker.dockerodeOptions have the current port?

Yup they are still accurate:

{
  "docker.dockerPath": "podman",
  "docker.host": "ssh://core@localhost:50685",
  "docker.explorerRefreshInterval": 5000,
  "docker.dockerodeOptions": {
    "socketPath": "ssh://core@localhost:50685/run/user/1000/podman/podman.sock"
  }
}
❯ podman system connection ls
Name                         Identity                                 URI
podman-machine-default*      /Users/btea/.ssh/podman-machine-default  ssh://core@localhost:50685/run/user/1000/podman/podman.sock
podman-machine-default-root  /Users/btea/.ssh/podman-machine-default  ssh://root@localhost:50685/run/podman/podman.sock

@bwateratmsft
Copy link
Collaborator

bwateratmsft commented Jan 6, 2022

Hm. I am stumped. Setting docker.host in addition to docker.dockerodeOptions did indeed skip that podman context ls ... logic but I am not sure what would cause the ENOENT error. I think that suggests a successful connection to ssh://core@localhost:50685 but /run/user/1000/podman/podman.sock was not found or not accessible. It's not ideal but can you try using root, with ssh://root@localhost:50685/run/podman/podman.sock, to see if that works?

It may also require a different SSH key with ssh-add.

@benatshippabo
Copy link
Author

benatshippabo commented Jan 6, 2022

Yeah, same error even when trying to connect as root user. 😞

@bwateratmsft
Copy link
Collaborator

@benatshippabo to make sure I set up a realistic repro, does your Mac have an Intel processor or the newer M1 (aka Apple Silicon)?

@benatshippabo
Copy link
Author

@benatshippabo to make sure I set up a realistic repro, does your Mac have an Intel processor or the newer M1 (aka Apple Silicon)?

It is on the M1 processor. Thanks @bwateratmsft

@bwateratmsft
Copy link
Collaborator

@philliphoff do you mind trying out the scenario on your M1? I'll try it out on my Intel Macbook and see how it goes.

@philliphoff
Copy link
Member

This is as far as I get with my M1 (the ENOENT error), and is the same whether I specifically set docker.host or not.

Screenshot 2022-01-19 at 12 25 44

@bwateratmsft
Copy link
Collaborator

bwateratmsft commented Jan 20, 2022

I was able to get the same results on my Intel Mac.

I've spent some time today looking into this. It seems things are going sideways in docker-modem. It successfully establishes a connection to the SSH host, whereupon it runs docker system dial-stdio in order to communicate with Docker on the host over ordinary HTTP tunneled through the SSH connection. Naturally, this is not going to work for Podman, since it's literally running a docker command.

dockerode / docker-modem accept a custom agent object which could probably be coerced into making it work, but it wouldn't be possible to use this with the Docker extension, because only JSON objects can be fed to docker.dockerodeOptions.

@benatshippabo bad news and good news. The bad news is that I don't think there's currently any way to make this work. The good news is that #3263 ought to solve this and we're hoping to get it in our next release. For now, I'll resolve this one as a dupe of that.

@bwateratmsft bwateratmsft removed this from the 1.20.0 milestone Jan 20, 2022
@benatshippabo
Copy link
Author

I was able to get the same results on my Intel Mac.

I've spent some time today looking into this. It seems things are going sideways in docker-modem. It successfully establishes a connection to the SSH host, whereupon it runs docker system dial-stdio in order to communicate with Docker on the host over ordinary HTTP tunneled through the SSH connection. Naturally, this is not going to work for Podman, since it's literally running a docker command.

dockerode / docker-modem accept a custom agent object which could probably be coerced into making it work, but it wouldn't be possible to use this with the Docker extension, because only JSON objects can be fed to docker.dockerodeOptions.

@benatshippabo bad news and good news. The bad news is that I don't think there's currently any way to make this work. The good news is that #3263 ought to solve this and we're hoping to get it in our next release. For now, I'll resolve this one as a dupe of that.

Yeah that makes sense to me. Thanks for keeping me posted @bwateratmsft

@microsoft microsoft locked and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants