You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
forwardPorts configuration option not working #186
With the recent release (the one with features) I tried experimenting with the devcontainers CLI. But I just can't get the forwardPorts feature to work. I created the following minimal devcontainer.json file:
Maybe I am misunderstanding the forwardPorts option, but I would expect that this configuration will forward the port 2222 (this is the default defined by the sshd feature) from the devcontainer to my host. But a simple ssh localhost -p 2222 did not work.
With the recent release (the one with features) I tried experimenting with the devcontainers CLI. But I just can't get the forwardPorts feature to work. I created the following minimal devcontainer.json file:
Maybe I am misunderstanding the forwardPorts option, but I would expect that this configuration will forward the port 2222 (this is the default defined by the sshd feature) from the devcontainer to my host. But a simple ssh localhost -p 2222 did not work.
How are you supposed to expose ports, if the option is not supported in devcontainer.json? I have tried looking through the cli tool (most naturally would think it fits in devcontainer up), but have not found anything.
Most simply, I am looking for something equivalent to docker run -p 8080:8080 ….
Something like this feels crucial to support individuals that don’t use vscode, but would rather dev in the container with vim / emacs.
Reacted by Anton Gilgur, Danny Elfanbaum, Igor Khramtsov, Pranithan, IBRAHIM MOHAMED FOUAD , Leo Cavalcante, Eyal Cherevatsky, Sam, Jono, Contention and 6 more
michaelperel, to my knowledge, port forwarding is not supported in the CLI via forward-port. You can use the appPort Option. I implemented basic port forwarding via the docker -p/--publish flag. Currently, it is still living here: https://github.com/MunsMan/devcontainercli/tree/port_forwarding
I will do a pull request after I added some testing. If you like, I would love feedback.
I truly agree that the Devcontainer CLI should support workflows independent of VS Code. I'm additionally developing auto-forwarding, but it will probably be a feature, which needs to be added to an Image. We will see.
Reacted by Alexander Pushkov, Henri, Colton Padden, Eyal Cherevatsky, jon r, Sam, Anton Gilgur, Nikolai Koudelia and Adheesh Trivedi
Is this issue still open after so many years? Has anyone found a solution or workaround?
Otherwise it seems impossible to use this CLI and an editor different from VS code...
appPort works as a workaround. It is not quite the same, though. One caveat to know about: the application running in the container would need to list on 0.0.0.0 for this to work.
Activity
Frankramos181422 commentedon Sep 22, 2022
chrmarti commentedon Sep 23, 2022
Port forwarding is currently not implemented in the CLI. Labelling as feature request.
MunsMan commentedon Feb 27, 2023
Is there any information about the intent of adding Port Forwarding to the
devcontainerCLI?michaelperel commentedon Mar 6, 2023
How are you supposed to expose ports, if the option is not supported in devcontainer.json? I have tried looking through the cli tool (most naturally would think it fits in
devcontainer up), but have not found anything.Most simply, I am looking for something equivalent to
docker run -p 8080:8080 ….Something like this feels crucial to support individuals that don’t use vscode, but would rather dev in the container with vim / emacs.
MunsMan commentedon Mar 6, 2023
michaelperel, to my knowledge, port forwarding is not supported in the CLI via
forward-port. You can use theappPortOption. I implemented basic port forwarding via the docker-p/--publishflag. Currently, it is still living here: https://github.com/MunsMan/devcontainercli/tree/port_forwardingI will do a pull request after I added some testing. If you like, I would love feedback.
I truly agree that the Devcontainer CLI should support workflows independent of VS Code. I'm additionally developing auto-forwarding, but it will probably be a feature, which needs to be added to an Image. We will see.
delijah commentedon Oct 24, 2023
Any progress on this? Would be awesome to get this feature!
agilgur5 commentedon Jul 16, 2024
I rebased this and made some minor modifications (simplifications and style etc) and put up a PR: #859
It looks like this was worked on in https://github.com/MunsMan/autoForward but was not completed?
GitHub Codespaces does have auto-forwarding, which is nice, not sure if VSCode does as well.
But while related, that's a separate feature from supporting plain
forwardPortsthreema-danilo commentedon Jan 7, 2026
This is a duplicate of #22, right?
collimarco commentedon Jun 12, 2026
Is this issue still open after so many years? Has anyone found a solution or workaround?
Otherwise it seems impossible to use this CLI and an editor different from VS code...
candidtim commentedon Jun 16, 2026
appPortworks as a workaround. It is not quite the same, though. One caveat to know about: the application running in the container would need to list on 0.0.0.0 for this to work.