Exercise - Add software to an existing container
Dev Container Features and a Dockerfile are excellent tool for adding new software to your container. You might find during a project that you want to include additional software in your dev container over time, like Node.js.
In this exercise, we'll look at how you can install a technology stack like Node in your container at any point.
Dev container Feature
Press F1 to open the Command Palette.
Type explorer and select View: Show Explorer.
Open the
.devcontainer
folder.Locate and open the
devcontainer.json
file.Add the following code to install Node.js via a Feature.
"features": { "ghcr.io/devcontainers/features/node:1": { "version": "18" } }
Save your project.
Open the Command Palette.
Type rebuild and select Dev Containers: Rebuild Container.
Check the Node version
Let's check to make sure Node installed correctly.
Press Ctrl + ` to open the integrated terminal in Visual Studio Code.
Enter the following code to check your version of Node:
node --version
You should see a version of Node as output in the terminal.
Congratulations! You customized your dev container even further by installing additional software.
Continue to the next unit for a quick knowledge check about dev containers in Visual Studio Code. After that, we'll summarize what we've covered in this Learn module.