-
Notifications
You must be signed in to change notification settings - Fork 221
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
feat: support forwardPorts
config
#859
base: main
Are you sure you want to change the base?
Conversation
- agilgur5 modification: rebased with `main`
- it doesn't cover all networking at this time Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Thanks for the PR! A few considerations: The Dev Containers extension for VS Code forwards the listed ports to a free port on the local machine (which might be different from where Docker runs). GitHub Codespaces also has its own port forwarding. Additionally using Could this be added behind a CLI option, so the above scenarios don't break? |
I would think that all of those scenarios should be handled already downstream, as the behavior is identical to
For a reference implementation, that seems pretty confusing to me: the spec is the source of truth, yet you also need a flag? That behavior would be "ignore the spec field by default unless I tell you otherwise", which is pretty confusing, esp for a reference implementation -- why would the reference ignore the spec? |
The extension uses VS Code's port forwarding which is temporary while VS Code is connected and also works when the VS Code window runs on a different machine than the Docker daemon. (It is not use Docker's port forwarding.) I think another approach would be to replicate the temporary forwarding as part of an additional CLI command which would keep running until the port forwarding is no longer required and only then would be terminated. |
Then it should already be ignoring this, no? As it already ignores
While this makes sense to me, this doesn't match the existing behavior of
But I don't think I realized I had also looked at microsoft/vscode-remote-release#1809, where you did say (almost 5 years ago):
and someone else said a bit further up in the thread:
So I assumed they're equivalent in a Docker-based implementation. I'm not sure if that's changed since then or that's specific to the VS Code extension, but since the devcontainer CLI is similarly Docker-based, I would think that applies the same?
This makes it sound like the extension is different these days (also is the extension not open source? I tried finding its implementation to compare), but I wonder if the same makes sense to apply to the CLI. At least in my usage, my devcontainer is only running ( |
Just to clarify: The Dev Containers extension for VS Code and GitHub Codespaces both use the Dev Containers CLI to create the dev container. We moved away ( |
A few questions for clarity:
Gotcha. And then they have their own forwarding implementation, right? How do they handle the existing
Yea that was my other concern -- with a separate command for this, it would be done while already running, meaning we can't use the Docker implementation and have to reimplement forwarding (which is a bit of a rabbit hole). Does it make sense to move/share the downstream implementations here? |
We left There is some basic forwarding code in the extension that is used to establish an initial connection for VS Code. VS Code then tunnels everything through that initial connection. That code assumes Node.js is available in the container - which is true when using VS Code and the VS Code Server. (The extension is not OSS.) |
Summary
Fixes #186 by adding
-p
args for allforwardPorts
, not justappPort
Details
normalizePorts
function used on bothappPort
andforwardPorts
concat
andflatMap
those two together into argsCredits to @MunsMan for the original variant listed in this comment #186 (comment): this commit: MunsMan@6909283
Notes for Reviewers
There didn't seem to be any existing tests for
appPort
that I could extend forforwardPorts
, afaict. Let me know if there's a proper place to add tests for this