🌐
GitHub
github.com › microsoft › vscode-dev-containers › blob › main › containers › python-3 › README.md
vscode-dev-containers/containers/python-3/README.md at main · microsoft/vscode-dev-containers
Beyond Python and git, this image / Dockerfile includes a number of Python tools, zsh, Oh My Zsh!, a non-root vscode user with sudo access, and a set of common dependencies for development. Given JavaScript front-end web client code written for use in conjunction with a Python back-end often requires the use of Node.js-based utilities to build, this container also includes nvm so that you can easily install Node.js. You can change the version of Node.js installed or disable its installation by updating the args property in .devcontainer/devcontainer.json.
Author   microsoft
🌐
GitHub
github.com › microsoft › vscode-remote-try-python
GitHub - microsoft/vscode-remote-try-python: Python sample project for trying out Dev Containers · GitHub
Tools are installed in the mcr.microsoft.com/devcontainers/python image and Dev Container settings and metadata are automatically picked up from image labels.
Starred by 919 users
Forked by 1.8K users
Languages   Python 73.7% | HTML 26.3%
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › tutorial
Dev Containers tutorial
November 3, 2021 - The Dev Containers extension uses the files in the .devcontainer folder, namely devcontainer.json, and an optional Dockerfile or docker-compose.yml, to create your dev containers.
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › create-dev-container
Create a Dev Container
November 3, 2021 - Python & PostgreSQL - A Python container that connects to PostgreSQL in a different container. Docker-Outside-of-Docker Compose - Includes the Docker CLI and illustrates how you can use it to access your local Docker install from inside a dev ...
🌐
Xebia
xebia.com › home › blog › how to create a devcontainer for your python project
How To Create A Devcontainer For Your Python Project | Xebia
November 21, 2022 - On top of python:3.10, we install Java and the required pip packages. The .devcontainer folder is in place, so it’s now time to open our Devcontainer. First, make sure you have the Dev Containers extension installed in VSCode (previously called “Remote - Containers”. That done, if you open your repo again, the extension should already detect your Devcontainer:
🌐
DEV Community
dev.to › jajera › python-development-in-vscode-using-devcontainer-2ao1
Python Development in VSCode Using Devcontainer - DEV Community
December 1, 2024 - Learn how to set up and use a devcontainer-based environment for Python development in VSCode using the devcontainer-python-template.
🌐
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"
}

🌐
Docker Hub
hub.docker.com › r › microsoft › devcontainers-python
microsoft/devcontainers-python - Docker Image
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 !
🌐
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" }
Find elsewhere
🌐
GitHub
github.com › microsoft › vscode-dev-containers › blob › main › containers › python-3 › .devcontainer › devcontainer.json
vscode-dev-containers/containers/python-3/.devcontainer/devcontainer.json at main · microsoft/vscode-dev-containers
November 30, 2023 - // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 · // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local on arm64/Apple Silicon. "VARIANT": "3.10-bullseye", // Options · "NODE_VERSION": "lts/*" } }, · // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. "vscode": { // Set *default* container specific settings.json values on container create.
Author   microsoft
🌐
Visual Studio Code
code.visualstudio.com › docs › containers › quickstart-python
Python in a container
November 3, 2021 - Develop, build, and debug a Python app in a container, using Visual Studio Code.
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › connect-multiple-containers
Connect to multiple containers
November 3, 2021 - You can then set up ./devcontainer/python-container/devcontainer.json for Python development as follows:
🌐
Docker Hub
hub.docker.com › r › microsoft › vscode-devcontainers
microsoft/vscode-devcontainers - Docker Image
mcr.microsoft.com/vscode/devcontainers/python (Details⁠, History⁠, All tags⁠) 3, 3.9, 3-bullseye, 3.9-bullseye, 3-buster, 3.9-buster · 3.8, 3.8-bullseye, 3.8-buster · 3.7, 3.7-bullseye, 3.7-buster · 3.6, 3.6-bullseye, 3.6-buster ·
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › tips-and-tricks
Dev Containers Tips and Tricks
November 3, 2021 - Add "github.copilot.chat.codeGeneration.instructions" directly in your devcontainer.json · We publish dev container resources (like images and Features) to make the process of creating and connecting to dev containers even easier, and we now include custom instructions in these files. Here is an example of custom instructions in the Python Feature.
🌐
Medium
medium.com › data-science › setting-a-dockerized-python-environment-the-elegant-way-f716ef85571d
Setting A Dockerized Python Environment — The Elegant Way | by Rami Krispin | TDS Archive | Medium
April 6, 2024 - The Dev Containers extension makes the integration of containers with the development workflow seamless and efficient. We saw how, with a few simple steps, we can set and customize a dockerized Python environment using the devcontainer.json file.
🌐
CloudBytes
cloudbytes.dev › snippets › use-vscode-devcontainers-instead-of-python-venv
Use VSCode Devcontainers instead of Python venv · CloudBytes/dev
July 7, 2021 - It will then ask you to choose one from ready-to-use configurations. Let’s choose Python3 & PostgreSQL. This will trigger two actions · Create a folder named .devcontainer in your project root directory that with a Dockerfile and a .devcontainer.json that contains your user configuration
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set. A devcontainer.json file in your project tells VS Code how to access (or create) a development container with ...
🌐
Flaviodelgrosso
flaviodelgrosso.com › blog › vscode-devcontainers
Mastering VS Code Dev Containers with Docker
February 4, 2024 - The simplicity of this configuration lies in referencing a prebuilt image from Microsoft's container registry (mcr.microsoft.com/devcontainers/python:1-3.12-bullseye).