Skip to content

Local development Environment

In this step you are going to install Docker, VS Code, and setup a DevContainer for your project.

Install Docker

MacOS and Windows should install Docker Desktop. Follow the instructions for MacOS or Windows

Verify your docker installation by running:

Terminal window
docker --version

Install Visual Studio Code

Install Visual Studio Code via your preferred option, such as the Webpage or a package manager. Verify your installation by opening Visual Studio Code.

Create a simple DevContainer

  • Open the command palette in Visual Studio Code by pressing Ctrl+Shift+P or Cmd+Shift+P on MacOS.
  • Type Dev Container: Add Dev Container Configuration Files... and select it.
    • Hint the search is fuzzy, so you can type dev add and it should show up.
  • When selecting the template, choose Ubuntu, with the default settings.
  • Select the features you need, for example Python, and press OK
    • You can select Keep Defaults in don’t need a certain version or extra features & tools.
  • Done!

You should now see a .devcontainer folder in your project with a devcontainer.json file.

.devcontainer/devcontainer.json
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/python:1": {}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

A popup should appear asking you to reopen the project in the DevContainer. Click Reopen in Container. If not, open the command palette and type Dev Container: Reopen in Container.

Verify that you are in the DevContainer by opening a terminal in Visual Studio Code and running:

Terminal window
python --version

You should see the Python version installed in the DevContainer:

Terminal window
vscode /workspaces/python-gh-actions $ python --version
Python 3.10.12