Skip to content

build(devcontainer): add ping, traceroute, mtr, nc and tcpdump - #5354

Merged
dan-petty merged 3 commits into
mainfrom
build/5343-devcontainer-network-tools
Nov 13, 2026
Merged

dan-petty merged 3 commits into
mainfrom
build/5343-devcontainer-network-tools

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The devcontainer image installs iputils-ping, iputils-tracepath, traceroute, mtr-tiny, netcat-openbsd and tcpdump with its other system packages, so a person can find the cause of a network fault in the container. dig and nslookup are in the image already.

runArgs of the workspace and of the devops devcontainer init template add --sysctl=net.ipv4.ping_group_range=1000 1000, so vscode (gid 1000) runs ping with no sudo. The value of the issue, 0 2147483647, stops the container under rootless Podman, because its user namespace does not map that gid. mtr-packet gets cap_net_raw from its package. tcpdump needs sudo, because a file capability lets each user of the container capture packets.

The smoke action of the image checks the six commands and a ping as vscode. docs/DEVCONTAINER_USAGE.md gives the tools and their limits.

Closes #5343

Change: openspec/changes/archive/2026-11-13-5343-devcontainer-network-tools/

The devcontainer image had no basic network diagnostics tools. The
system-package step of the image now installs iputils-ping,
iputils-tracepath, traceroute, mtr-tiny, netcat-openbsd and tcpdump.
A feature of the image installs dig and nslookup already.

Debian's ping opens an ICMP echo socket and has no file capability,
and Podman lets only group 0 open one. The run argument
--sysctl=net.ipv4.ping_group_range=1000 1000 lets the group of vscode
open the socket. Under rootless Podman with keep-id, gid 1000 maps to
the lowest host ID of the container, so the range starts at 1000. The
value 0 2147483647 stops the container at its start, because the user
namespace does not map the upper bound. The workspace and the
scaffolded devcontainer get the same run arguments.

mtr-packet gets cap_net_raw from its package. tcpdump needs sudo.
docs/DEVCONTAINER_USAGE.md gives these limits and the pasta limit for
ICMP path traces. A person must rebuild the devcontainer.
The smoke action starts the built image as vscode with the run argument
--sysctl net.ipv4.ping_group_range=1000 1000. It fails when ping,
tracepath, traceroute, mtr, nc or tcpdump is not on the path, or when
ping -c 1 127.0.0.1 fails. The test of the Dockerfile reads only text.

The manual configuration of docs/DEVCONTAINER_USAGE.md holds the run
argument. The document says when ping needs sudo: with no run argument
under rootless Podman, and when the gid of vscode is not 1000.
@dan-petty dan-petty added type/infra Type infra: the build, CI, images or cluster scope/devcontainer The DevContainer, its image and its features labels Nov 13, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Owner action: rebuild the devcontainer

After the release publishes the image, rebuild the devcontainer (Dev Containers: Rebuild Container). A restart or a reload does not apply a new run argument or a new package. Then run these commands as vscode:

cat /proc/sys/net/ipv4/ping_group_range   # shows 1000 1000
ping -c 1 example.com
tracepath -n example.com
mtr --report -c 1 example.com
nc -zv example.com 443
sudo tcpdump -c 1

Limits (in docs/DEVCONTAINER_USAGE.md): tcpdump needs sudo. Under pasta, mtr and traceroute -I show only the destination; tracepath and traceroute (UDP) show each hop. ping as vscode works only while the gid of vscode is 1000.

Differences from the issue

  • The issue proposes --sysctl=net.ipv4.ping_group_range=0 2147483647. The rootless Podman user namespace does not map gid 2147483647, so the kernel refuses the value and the container does not start. With keep-id, gid 1000 maps to a host ID below the host ID of gid 0, so 0 65536 starts but ping as uid 1000 fails. The change uses 1000 1000. Evidence: a nested Docker test in the running devcontainer (same user namespace) and the Moby source, which sets the wide range only outside a user namespace.
  • No --cap-add=NET_RAW: the docker-in-docker feature runs the container privileged, so the bounding set is full already, and the capability has no effect for a non-root user.
  • The run argument is also in the devops devcontainer init template, and a test keeps the two runArgs lists equal.

Review fixes (reviewer)

  • The smoke action .github/actions/devcontainer-smoke now starts the built image as vscode with the run argument. It fails when ping, tracepath, traceroute, mtr, nc or tcpdump is not on the path, or when ping -c 1 127.0.0.1 fails. Before, only a text test of the Dockerfile covered the packages. A nested Docker test (no privilege, uid 1000, pinned debian:sid with iputils-ping) showed that this ping works with 1000 1000 and fails with 0 0.
  • The manual configuration of docs/DEVCONTAINER_USAGE.md holds the run argument. The document now says when ping needs sudo: with no run argument under rootless Podman, and when VS Code changes the gid of vscode (updateRemoteUserUID).
  • The verification line of the document task used git grep, which the plan step refuses. It is now uv run devops ci docs.

Checks run

  • Red first (builder): uv run devops ci test tests/invariants/test_devcontainer_config.py: 2 new tests failed before the change.
  • Red first (reviewer): uv run devops ci test tests/invariants/test_workflow_contracts.py -k smoke: 1 failed before the action change, passes after.
  • uv run devops ci test tests/invariants tests/core/test_template_rendering.py tests/commands/test_devcontainer.py tests/commands/test_ci.py: 1105 passed.
  • uv run devops ci --check --only lint,format,domain,docs,actionlint,zizmor,openspec,devcontainer: all pass.
  • uv run devops ci typecheck: no issues in 841 source files.
  • uv run devops openspec check and uv run devops openspec archive: pass.
  • Builder: trivy config on .devcontainer: the same 6 findings as origin/main, no new finding.
  • Builder: a test image of the pinned debian:sid with the new apt step, privileged, uid 1000: ping, tracepath, traceroute, mtr --report and nc -zv pass; tcpdump needs root; mtr-packet has cap_net_raw=ep.
  • Nobody built the full image locally. The DevContainer Image job builds it on this pull request and runs the smoke action.

Render diff

The change touches no k8s/ path and no chart values, so there is no render diff, and nothing deploys to the cluster.

@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 04:29
@dan-petty
dan-petty merged commit 5466f8c into main Nov 13, 2026
25 checks passed
@dan-petty
dan-petty deleted the build/5343-devcontainer-network-tools branch November 13, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/devcontainer The DevContainer, its image and its features type/infra Type infra: the build, CI, images or cluster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build(devcontainer): add ping, traceroute, mtr, nc and tcpdump

1 participant