Creating a dev container
To add a dev container to a project, we need to create a .devcontainer
folder with two files:
Dockerfile
to describe the container image to build and rundevcontainer.json
to add additional configuration
This combination of files will give us a single-container configuration. Remote-Containers also supports a multi-container configuration using Docker Compose (see https://code.visualstudio.com/docs/remote/create-dev-container#_using-docker-compose) but we will focus on the single-container scenario for this chapter.
The accompanying code for the book contains a sample project that we will use to explore dev containers. Ensure that you clone the code from https://github.com/PacktPublishing/Windows-Subsystem-for-Linux-2-WSL-2-Tips-Tricks-and-Techniques in a Linux distribution. Once the code is cloned, open the chapter-10/01-web-app
folder in Visual Studio Code (there is also a chapter-10/02-web-app-completed
folder with all of the steps...