Skip to content

Workaround for Dev Containers CLI forwarded port issue (3000 not matched) #33

@ronald2wing

Description

@ronald2wing

Describe the bug
The Dev Containers CLI currently has an upstream issue where forwarded ports from devcontainer.json are not properly handled or exposed in some cases:

devcontainers/cli#22

Because of this, the devcontainer-cli.nvim plugin does not correctly recognize or match forwarded ports such as 3000.

Even though this originates from the upstream CLI behavior, the plugin could potentially implement a workaround by reading forwardPorts directly from devcontainer.json and handling the mapping internally.

To Reproduce
Steps to reproduce the behavior:

  1. Create a .devcontainer/devcontainer.json file with:
    {
      "forwardPorts": [3000]
    }
    
    
  2. Open the project in Neovim using the plugin
  3. Start or attach to the devcontainer using the plugin commands
  4. Run an application inside the container that listens on port 3000
  5. Observe that the plugin does not correctly detect or expose port 3000

Expected behavior
The plugin could provide a workaround for the upstream Dev Containers CLI limitation by:

  • parsing forwardPorts from devcontainer.json
  • tracking configured ports internally
  • exposing or forwarding those ports even if the CLI does not report them correctly

This would improve the development experience for common web frameworks that default to port 3000.

Screenshots
If applicable, add screenshots showing:

  • devcontainer.json
  • container logs
  • Neovim output/messages
  • port forwarding behavior

Desktop (please complete the following information):

  • OS: Linux
  • Neovim Version: v0.12.2
  • Plugin Version: latest
  • Devcontainer CLI Version: v0.86

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context
This issue originates from the upstream Dev Containers CLI behavior:
devcontainers/cli#22

Since VS Code Dev Containers already handles forwarded ports well, adding a plugin-side workaround could help provide a smoother and more expected devcontainer experience inside Neovim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions