no-app-port

disallow the legacy “appPort” property in favor of “forwardPorts”

Category
style
Applies to
devcontainer
Platforms
all

Why

“appPort” publishes the port the way Docker does: it is fixed when the container is created, and the application has to listen on all interfaces rather than just “localhost” to be reachable. A forwarded port instead looks like “localhost” to the application and can be changed without recreating the container, which is why the reference recommends “forwardPorts” in most cases.

Bad

{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "appPort": [3000]
}

Good

{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "forwardPorts": [3000]
}

References