DevTools Logo

Dev Container Config Generator

Dev Container Config Generator

Build a schema-shaped devcontainer.json from images, features, extensions, ports and lifecycle hooks.

Runs in your browser
Try an example

Container setup

0 features · 0 extensions

Base

Features
Extensions
Lifecycle commands

Runs on the host before the container is created (e.g. secrets, host setup).

Runs inside the container once, right after it is first created — typical spot for npm install.

Runs every time the container starts, after create.

Runs each time an editor attaches to the running container.

devcontainer.json

JSONC with explanations

Valid JSON · place at .devcontainer/devcontainer.json

Examples

TypeScript Node

Input
image: typescript-node · ESLint + Prettier · npm install
Output
devcontainer.json with extensions, forwardPorts: [3000] and postCreateCommand

The default stack preset produces a working Node dev container in one click.

Dockerfile build

Input
build.dockerfile: Dockerfile · context: .. · args: NODE_ENV=dev
Output
build block with args instead of an image key

Build mode wraps a custom image with editor configuration and features.

Feature refs

Input
docker-in-docker + git, version 1
Output
ghcr.io/devcontainers/features/docker-in-docker:1 with { version: 1 }

Current OCI syntax replaces the deprecated legacy feature URL form.

About this tool

The Dev Container Config Generator builds a valid .devcontainer/devcontainer.json from a guided form. Start from a prebuilt image or a Dockerfile, add pinned Dev Container features, choose editor extensions, forward ports and describe lifecycle commands — the output is a correctly ordered config you can copy into your repository.

Every section has an explanation attached. Features use the current OCI registry references with major-version pins; extensions are linted against the publisher.name shape; port numbers are checked against 1–65535. The one-of image/build rule is enforced so the generated file matches the schema.

Choose JSONC to see comments that explain each section, or strict JSON for schema validators and CI. Lifecycle hooks are documented inline: initializeCommand runs on the host before create, postCreateCommand runs once after creation, postStartCommand on every start and postAttachCommand on every editor attach.

What this tool does not do

  • Lifecycle commands are emitted as text; the tool never executes them. Review any imported config before opening it in an editor.
  • Feature options are linted against a bundled catalog of common features; new feature schemas may need manual review.
  • Docker Compose support covers the file/service/workspaceFolder references only — it does not author compose services.

How to use this tool

  1. Pick a base

    Select image, build or compose mode; choose a prebuilt stack image or point at a Dockerfile with its context and args.

  2. Add features and extensions

    Tick features from the catalog (pinned to :1) and paste or pick extension IDs such as dbaeumer.vscode-eslint.

  3. Configure ports and hooks

    List forwarded ports and add lifecycle commands; each hook shows when it runs next to its input.

  4. Copy the config

    Switch between commented JSONC and strict JSON, check the validation badge, then copy or download into .devcontainer/devcontainer.json.

Use cases

Team onboarding

Standardise the container image, extensions and lifecycle commands every contributor gets on first open.

OSS contributions

Add a devcontainer for contributors without hand-writing schema-sensitive JSON.

Codespaces customization

Use the same config for local Dev Containers and GitHub Codespaces, with port attributes and settings.

Output key order

KeyMeaning
nameFriendly name in the Dev Containers UI
image | buildMutually exclusive base: prebuilt image or Dockerfile build block
featuresOCI feature refs with version options
customizations.vscodeExtensions and editor settings
forwardPorts / portsAttributesForwarded ports and per-port labels
containerEnv / remoteUserEnvironment and runtime user
initializeCommand … postAttachCommandLifecycle hooks in execution order

JSONC and strict JSON are derived from the same object, so the models are always identical after comments are stripped.

Common mistakes

Mistake:Setting both image and build.

Fix:The devcontainer schema treats them as mutually exclusive — the generator enforces one-of and shows an error when both are present.

Mistake:Pinning a feature to :latest.

Fix:Prefer a major-version pin like :1 so feature option schemas stay stable; the tool warns about :latest.

Mistake:Expecting lifecycle commands to run in order listed.

Fix:initializeCommand runs on the host before create, then postCreate, postStart and postAttach run in the container at their respective stages — the hints next to each field explain this.

Frequently asked questions

Image or Dockerfile — which should I use?

Use an image when a prebuilt dev container image already matches your stack (for example mcr.microsoft.com/devcontainers/typescript-node) — it is faster and less to maintain. Use a build block when you need a custom Dockerfile with extra packages or build args. The two keys are mutually exclusive in devcontainer.json, and the generator enforces that rule.

What are dev container features?

Features are self-contained install scripts referenced by OCI URLs such as ghcr.io/devcontainers/features/docker-in-docker:1. They add tools to a running dev container without you authoring a Dockerfile. The generator's catalog includes Git, Node, Python, Java, Go, Terraform, common-utils and both Docker variants, with major-version pins and documented option keys.

When does postCreateCommand run?

postCreateCommand runs once, inside the container, right after it is first created — the usual place for npm install or pip install. postStartCommand runs each time the container starts, postAttachCommand each time an editor attaches, and initializeCommand runs on the host before the container is created. The hints beside each field repeat this sequence.

How do I forward ports?

Enter the port numbers in the Forward ports field, separated by commas or spaces — for example 3000, 5432. They are emitted as a forwardPorts array. Per-port labels go into portsAttributes and defaults into otherPortsAttributes. Numbers outside 1–65535 are rejected with an inline error.

Can I use docker-compose inside a dev container?

Yes — switch to compose mode and the generator emits dockerComposeFile, service and workspaceFolder instead of image/build. It references an existing compose file; it does not author compose services for you. Feature and extension configuration still applies on top.

References & standards