In my case, I could not use runArgs in the devcontainer.json because we are using dockerComposeFile.

The solution was to configure the per-service platform inside the relevant docker-compose.yml, e.g.:

version: "3"
services:
  some-service-only-as-amd64:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 5000:5000
    volumes:

# ... and so on

Answer from Charl Botha on Stack Overflow
🌐
Microsoft
mcr.microsoft.com › en-us › product › devcontainers › python › about
Python Development Container Images
You can opt into using the vscode non-root user in the container by adding "remoteUser": "vscode" to devcontainer.json. However, by default, this you will need to use sudo to perform global pip installs. ... If you prefer, you can add the following to your Dockerfile to cause global installs to go into a different folder that the vscode user can write to. ENV PIP_TARGET=/usr/local/pip-global ENV PYTHONPATH=${PIP_TARGET}:${PYTHONPATH} ENV PATH=${PIP_TARGET}/bin:${PATH} RUN if !
Discussions

Specify platform for Docker image in Visual Studio Code DevContainers - Stack Overflow
I'm using a MacBook Pro with the M2 processor (arm64) but I need to start a devcontainer with an amd64 version of the Python image (buster): Docker image: mcr.microsoft.com/devcontainers/python:0-3... More on stackoverflow.com
🌐 stackoverflow.com
How fix Python import error in VS Code editor when using a Dev Container? - Stack Overflow
I've opened a project with the following structure in VS Code (1.71.0 on macOS, Intel) and activated a Dev Container (I've tried the default Python 3.9 and 3.10 containers from Microsoft, with and More on stackoverflow.com
🌐 stackoverflow.com
Python Devcontainer Setup for VSCode
You don't really need a separate virtualenv if you're using a container. More on reddit.com
🌐 r/vscode
2
1
September 28, 2023
Docker Devcontainers in VScode is really slow
What base image are you using? More on reddit.com
🌐 r/docker
9
2
July 2, 2023
🌐
Docker Hub
hub.docker.com › r › microsoft › devcontainers-python
microsoft/devcontainers-python - Docker Image
Develop Python 3 applications. See history⁠ for information on the contents of published images. You can directly reference pre-built versions of Dockerfile by using the image property in .devcontainer/devcontainer.json or updating the FROM statement in your own Dockerfile with one of the following: ... mcr.microsoft.com/devcontainers/python:3.9 (or 3.9-trixie, 3.9-bookworm, 3.9-bullseye to pin to an OS version)
🌐
GitHub
github.com › microsoft › vscode-remote-try-python
GitHub - microsoft/vscode-remote-try-python: Python sample project for trying out Dev Containers · GitHub
The Code Spell Checker extension was automatically installed because it is referenced in .devcontainer/devcontainer.json. Also notice that utilities like pylint and the Python extension are installed. Tools are installed in the mcr.microsoft.com/devcontainers/python image and Dev Container ...
Starred by 919 users
Forked by 1.8K users
Languages   Python 73.7% | HTML 26.3%
🌐
Microsoft Community Hub
techcommunity.microsoft.com › microsoft community hub › communities › topics › education sector › educator developer blog
Teaching Python with GitHub Codespaces | Microsoft Community Hub
June 3, 2025 - { "name": "Python 3.13 playground", "image": "mcr.microsoft.com/devcontainers/python:3.13-bullseye", "customizations": { "vscode": { "settings": { "python.defaultInterpreterPath": "/usr/local/bin/python", "python.linting.enabled": true }, "extensions": [ "ms-python.python", "ms-python.vscode-pylance", "ms-python.vscode-python-envs" ] } } }
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › create-dev-container
Create a Dev Container
November 3, 2021 - { "build": { "dockerfile": "Dockerfile" }, "customizations": { "vscode": { "extensions": ["dbaeumer.vscode-eslint"] } }, "forwardPorts": [3000] } When you make changes like installing new software, changes made in the Dockerfile will persist even upon a rebuild of the dev container. In your Dockerfile, use FROM to designate the image, and the RUN instruction to install any software. You can use && to string together multiple commands. FROM mcr.microsoft.com/devcontainers/javascript-node:0-18 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install git
🌐
Microsoft
mcr.microsoft.com › vscode › devcontainers › python
Microsoft Artifact Registry
Microsoft Artifact Registry (also known as Microsoft Container Registry or MCR) Discovery Portal
Find elsewhere
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › tutorial
Dev Containers tutorial
November 3, 2021 - You can explore this image in greater detail in the devcontainers/images repo. First, your image is built from the supplied Dockerfile or image name, which would be mcr.microsoft.com/devcontainers/javascript-node:0-18 in this example. Then a container is created and started using some of the settings in the devcontainer.json.
🌐
Medium
andypickup.com › developing-in-python-with-dev-containers-part-1-setup-f1aeb89cbfed
Developing in Python with Dev Containers — Part 1: Setup | by Andy Pickup | Medium
April 15, 2024 - Line 18 — I use customisations to tailor my VSCode initialisation and get the extensions I use all the time installed plus any other useful settings. See below. Line 21 — When I’m using a Dockerfile I tend to create a non-root user and then I’ll make sure that’s referenced here. For simplicity, clear out all the comments and you should be here: { "name": "Python 3", "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", "remoteUser": "vscode" } Customisations ·
🌐
Docker Hub
hub.docker.com › r › microsoft › vscode-devcontainers
microsoft/vscode-devcontainers - Docker Image
mcr.microsoft.com/vscode/devcontainers/go (Details⁠, History⁠, All tags⁠)
🌐
GitHub
github.com › devcontainers › images › discussions › 1690
Container images: mcr.microsoft.com vs GitHub DevContainers ghcr.io/devcontainers? · devcontainers/images · Discussion #1690
Background I am trying to do add a DevContainer setup for a Python project. The VSCode extension/DevContainer itself recommended mcr.microsoft.com/devcontainers/python:2-3.14-trixie (yes this exact...
Author   devcontainers
🌐
Medium
medium.com › jon-backhaus › your-vs-code-project-needs-a-development-container-8643299f560c
Your VS Code Project Needs A Development Container | by Jon Backhaus | Jon Backhaus’ Blog
June 14, 2024 - { "name": "Python 3", "image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye" // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. "vscode": { // Add the IDs of extensions you want installed when the container is created.
🌐
Medium
medium.com › marvelous-mlops › how-to-start-with-dev-containers-1e92bf0e0f78
How to start with Dev Containers. Using a virtual environment to isolate… | by Başak Tuğçe Eskili | Marvelous MLOps | Medium
January 3, 2024 - # For more information, please refer to https://aka.ms/vscode-docker-python FROM python:3.8-slim-buster # Upgrade pip RUN python -m pip install --upgrade pip COPY requirements.txt /tmp/pip-tmp/ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ && rm -rf /tmp/pip-tmp · You can still use a pre-defined container configuration from devcontainer registry provided by Microsoft and additional steps in Dockerfile. FROM mcr.microsoft.com/devcontainers/python:1-3.10-bullseye # Upgrade pip RUN python -m pip install --upgrade pip COPY requirements.txt /tmp/pip-tmp/ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ && rm -rf /tmp/pip-tmp
🌐
Rost Glukhov
glukhov.org › home › developer tools: the complete guide to modern development workflows › mastering dev containers in vs code
Mastering Dev Containers in VS Code - Rost Glukhov | Personal site and technical blog
# GitHub Actions example name: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest container: image: mcr.microsoft.com/devcontainers/javascript-node:18 steps: - uses: actions/checkout@v3 - run: npm install - run: npm test
🌐
GitHub
github.com › nianwu › mcr.microsoft.com-vscode-devcontainers-python
GitHub - nianwu/mcr.microsoft.com-vscode-devcontainers-python
Contribute to nianwu/mcr.microsoft.com-vscode-devcontainers-python development by creating an account on GitHub.
Author   nianwu
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - { "image": "mcr.microsoft.com/devcontainers/typescript-node", "forwardPorts": [3000], "customizations": { // Configure properties specific to VS Code. "vscode": { // Add the IDs of extensions you want installed when the container is created.
🌐
Reddit
reddit.com › r/vscode › python devcontainer setup for vscode
r/vscode on Reddit: Python Devcontainer Setup for VSCode
September 28, 2023 -

I'm starting to look into devcontainers with VSCode and I am looking for a container configuration (Dockerfile/devcontainer.json) that sets up a good Python development environment with some recommended extensions and settings (e.g. paths, venv, fromatting, linting) for beginners (its been some time since I was doing Python development), but that's not over-complicated.

I have the following resources that I have pieced together as a starting point and could use some input and feedback on these (I'm not sure if everything makes sense) and what to improve for a good development experience. Particularly I'm looking for input on the VSCode extensions / settings.

docker-compose.dev.yaml

version: '3.9'

networks: app-dev-network: 
    driver: bridge 
    name: app-dev-network

services:

backend:

    image: backend-dev-image
    container_name: backend-dev-container
    build:
        context: ./
        dockerfile: ./Dockerfile.dev
    volumes:
        - ..:/workspace:cache
    networks:
        - app-dev-network
    ports:
        - target: 5000 
          published: 5000

    command: sleep infinity

Dockerfile.dev

ARG VARIANT="3.11-bookworm" 
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}

RUN apt-get update && \    
apt-get upgrade --yes --no-install-recommends && \    
apt-get clean

ENV PYTHONUNBUFFERED=1

devcontainer.json

{
    "name": "Backend",
    "dockerComposeFile": [
        "./docker-compose.dev.yaml"
    ],
    "service": "backend",
    "workspaceFolder": "/workspace",

    "customizations": {  
        "vscode": {  
            "extensions": [  
                "ms-python.python",  
            ],  
            "settings": {  
                "python.pythonPath": "${workspaceFolder}/.venv/bin/python",             
                "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",  
            }  
        }  
    },

    "postCreateCommand": "pip3 install --user -r requirements.txt"
}