Reproducible Dev Environments with devcontainer.json and the DevContainers CLI
Intermediate · 30 minutes · 100 points
In this lab you will scaffold a sample Node.js application, author a complete devcontainer.json that declares Features and a postCreateCommand script, install the @devcontainers/cli tool-chain, and then build and run the dev container headlessly inside the lab container, which runs its own Docker daemon (Docker-in-Docker) with Node.js installed — proving the environment boots identically on any machine without VS Code.
What you’ll learn
- Scaffold a minimal Node.js sample application with a package.json and index.js
- Author a valid devcontainer.json that uses at least one Feature and defines a postCreateCommand
- Install the @devcontainers/cli npm package globally and verify it is available
- Build the dev container image headlessly using the devcontainers CLI
- Run the dev container headlessly and confirm the postCreateCommand executed successfully
How this lab works
- Start the lab: One click starts a container on your computer with a real terminal: nothing to install by hand, nothing to clean up.
- Work through 5 tasks: Each task says what to build or fix. You do it yourself, in a real terminal, with hints when you get stuck.
- Check your work: Check my work runs each task’s checks in your container and says what passed and what to fix.
- Finish and keep going: 100 points, your progress saved, and the next lab to try.
What it runs on
- Runs: A container on your computer, with a real terminal
- Image: docker:28.5.2-dind
What you need
- A free LearnXops account
- The LearnXops desktop app for macOS, Windows or Linux
- Docker Desktop installed and running
Topics: devcontainers, docker, node, developer-experience, reproducibility, cli, devcontainer-features, headless
Create a free account to start this lab.