fix: SSH docker host tunneling on Windows#794
Open
ShortArrow wants to merge 1 commit into
Open
Conversation
Use TCP port forwarding instead of Unix socket forwarding on Windows, where paths contain ':' conflicting with SSH's -L delimiter. Also replace hardcoded /tmp with os.TempDir().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tunnel ssh docker host: create ssh tunnel tmp file: GetFileAttributesEx /tmp: The system cannot find the file specified.error when usingdocker context usewith an SSH context on WindowsDOCKER_HOST=tcp://localhost:PORT) instead of Unix socket forwarding (DOCKER_HOST=unix://...), because Windows paths contain:which conflicts with SSH's-L local:remotedelimiter/tmpwithos.TempDir()(returns/tmpon these platforms, so no behavioral change)Fixes #770
Related
ssh://scheme for docker client host #268 — Original PR that introduced SSH support with hardcoded/tmpWhat changed
pkg/commands/ssh/ssh.goTwo problems existed for Windows:
/tmpis hardcoded as the temp directory — does not exist on Windowsssh -L <local_socket>:<remote_socket>uses:as delimiter — Windows paths likeC:\Users\...\dockerhost.sockcontain:which breaks the parsingThe fix introduces platform-aware tunneling by splitting
createDockerHostTunnelinto Unix and TCP variants:createDockerHostTunnelTCP):ssh -L localhost:<free_port>:/var/run/docker.sockwithDOCKER_HOST=tcp://localhost:<port>createDockerHostTunnelUnix):ssh -L <tmpdir>/dockerhost.sock:/var/run/docker.sockwithDOCKER_HOST=unix://<tmpdir>/dockerhost.sock(existing behavior,/tmp→os.TempDir())Both variants share
retrySocketDial/tryDial(addednetworkparameter) andtunnelSSH(unchanged).pkg/commands/ssh/ssh_test.goTestCreateDockerHostTunnelUnix— tests the Unix socket path directlyTestCreateDockerHostTunnelTCP— tests the TCP port forwarding path directlycreateDockerHostTunnelTCP(findFreePortfailure,tunnelSSHfailure)Known limitations
ssh -Lbinds it.Test plan
go test ./pkg/commands/ssh/...passes on all platforms