Docker - Even easier setup of Python
Streamline your Python development. This guide shows you how to use Docker and Microsoft Devcontainers for an incredibly easy and reproducible Python environment setup.
This article is part of the Coding using a devcontainer series:
- PHP development in a devcontainer with preinstalled code quality tools
- Install a PHP Docker environment in a matter of seconds
- Docker - Python devcontainer
- Docker - Easy setup of Python under Windows
- Docker - Even easier setup of Python
- One Docker Image for Production and Devcontainers - The Clean Way
- Level Up Your Presentations with Quarto, reveal.js, Decktape, Docker and DevContainers
Changelog

This article shows the fastest way yet to get a Python devcontainer: with Docker and the VSCode Docker extension installed, use the Command Palette's built-in "Dev Containers: Add Dev Container Configuration files..." wizard to auto-generate .devcontainer/devcontainer.json for Python, then click "Reopen in Container" — no manual file creation needed at all.
Nothing to install, nothing to configure, nothing to create first.
In a previous article (and its Windows-specific follow-up), I built the Dockerfile, compose.yaml and devcontainer.json files by hand. Turns out VSCode can generate all of that for you.
Here is how to use VSCode and Docker to create a ready-to-use Python environment, whether you're under Windows, Linux, or Mac.
The wizard is the fastest route, but writing the files yourself is what lets you control exactly what goes into the image — and keep development tooling out of production, as explained in One Docker Image for Production and Devcontainers - The Clean Way.
The only prerequisites are:
- You should have Docker installed on your system
- You should have Visual Studio Code
- You've installed the Docker for Visual Studio Code addon in VSCode
Here's the payoff. Once the devcontainer is up, create a new file called main.py with this line print("Hello from your Python Devcontainer!").
Save the file.
Click in the terminal and type python main.py to execute the script and tadaaa:

A working Python environment, terminal and interpreter ready, and not a single file created by hand. Here's how VSCode builds it for you.
If you have these three things, just do this:
- Start Visual Studio Code
- Press CTRL+SHIFT+P to open the Command Palette.
- Select Dev Containers: Add Dev Container Configuration files...
- And follow the wizard:
- Search for Python
- Select the most recent version of Python, right now it's
3.13-bookworm - No need to install additional features, just press Enter
- Same for optional files; not needed, just press Enter
This done, VSCode will create a file called .devcontainer/devcontainer.json.

See bottom right, please click on the Reopen in Container button.
Depending on the speed of your computer and if things were already downloaded, you'll get this screen:

See the bottom part, a terminal window has been displayed and you've a prompt showing vscode -> /workspaces/python $.
Click in the terminal and type python --version:
This article is part of the Coding using a devcontainer series:
- PHP development in a devcontainer with preinstalled code quality tools
- Install a PHP Docker environment in a matter of seconds
- Docker - Python devcontainer
- Docker - Easy setup of Python under Windows
- Docker - Even easier setup of Python
- One Docker Image for Production and Devcontainers - The Clean Way
- Level Up Your Presentations with Quarto, reveal.js, Decktape, Docker and DevContainers





