2b Activity: Devcontainers and Codespaces
Goal
We will add our own devcontainer configuration to the practice repository from 2a.
Note: The checkboxes on this page are only stored locally in your browser. They are not submitted or synced anywhere.
Progress: 0 / 0 steps complete.
Activity
Start on GitHub in Chrome or Edge.
- Open the
python_tmr_practicerepository you created in2a. - Click the green Code button.
- Click the Codespaces tab.
- Open the existing Codespace, or create a new one if needed.
In VS Code Web:
- Open the Command Palette with F1 or Shift+Command+P.
- Search for add dev.
- Choose Codespaces: Add Dev Container Configuration Files….
- Choose a Python configuration.
- If asked for a Python version, choose Python 3.13 if it is available. Otherwise, accept the default.
- Accept the remaining default options.
The exact list of choices can change a little over time. The important thing is that we are adding a .devcontainer/ folder to the repository.
Open .devcontainer/devcontainer.json.
Look for:
- the name of the configuration;
- the base image or feature choices;
- any VS Code extension recommendations;
- any setup commands.
Do not worry if your file does not match the course repository.
VS Code may ask whether you want to rebuild or reopen the Codespace using the new configuration.
Once you’re finished editing, you can follow the prompts to rebuild or use the Command Palette to search for and choose Codespaces: Rebuild Container.
The key thing to note is that the repository now contains our environment recipe.
Use Source Control:
- Review the
.devcontainer/changes. - Find the
.devcontainer/files under Changes. - Hover over each file and click the + button to stage it.
- Confirm that the files moved from Changes to Staged Changes.
- Commit with a message such as:
Added Python devcontainer configuration.
Push or sync the commit to GitHub.