Validate devcontainer.json files for VS Code Dev Containers, GitHub Codespaces, and DevPod.
Checks your devcontainer.json (JSONC — comments and trailing commas supported) for common mistakes across six areas:
CategoryRulesExamplesStructure (6)Invalid JSONC syntax, missing image source, unknown top-level keys, empty name, image+dockerFile conflict, dockerFile+compose conflict"image": "...", "dockerFile": "..." both setFeatures (4)Invalid features format, feature ID not valid OCI ref, empty feature options, duplicate features"features": ["go"] (should be object)Ports & networking (4)forwardPorts not array, invalid port numbers, port out of range, portsAttributes referencing unlisted ports"forwardPorts": [99999]Lifecycle scripts (4)Invalid command type, empty commands, shell injection patterns, onCreateCommand usage hints"postCreateCommand": ""Customizations (3)extensions not array of strings, invalid extension ID format, settings not object"extensions": [123]Best practices (3+)Missing remoteUser (root warning), privileged: true, missing workspaceFolder, dangerous capAdd entries"capAdd": ["SYS_ADMIN"]
0 — no errors (warnings/info allowed)1 — errors found (or --strict with any issue)2 — file not found or parse errorFull validation of all rules.
bash
python3 scripts/devcontainer_validator.py validate devcontainer.json
python3 scripts/devcontainer_validator.py validate --format json .devcontainer/devcontainer.json
python3 scripts/devcontainer_validator.py validate --strict devcontainer.json
Validate only structure rules (required fields, conflicts, unknown keys).
bash
python3 scripts/devcontainer_validator.py structure devcontainer.json
Validate only the features section.
bash
python3 scripts/devcontainer_validator.py features devcontainer.json
Validate only security-related rules (privileged, capAdd, shell injection, remoteUser).
bash
python3 scripts/devcontainer_validator.py security --strict devcontainer.json
OptionValuesDefaultDescription--formattext, json, summarytextOutput format--min-severityerror, warning, infoinfoFilter by minimum severity--strictflagoffExit 1 on any issue
bash
# Quick check
python3 scripts/devcontainer_validator.py validate devcontainer.json
# CI pipeline
python3 scripts/devcontainer_validator.py validate --strict --format summary devcontainer.json
# Security audit only
python3 scripts/devcontainer_validator.py security --format json devcontainer.json
# Filter noise
python3 scripts/devcontainer_validator.py validate --min-severity warning devcontainer.json