Skip to content

VSCode Dev Container

{
    "name": "<name>",
    "dockerFile": "Dockerfile",
    "context": "..",
    "workspaceFolder": "/workspaces/<host folder name>",
    "remoteUser": "user",
    "runArgs": [
        "--net=host",
        "--hostname=<name>",
        "--add-host=<name>:127.0.0.1"
    ],
    "remoteEnv": {
        "DISPLAY": "${localEnv:DISPLAY}",
        "QT_X11_NO_MITSHM": "1"
    },
    "mounts": [
        "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind",
        "source=/dev/dri,target=/dev/dri,type=bind"
    ],
    "postCreateCommand": "/home/user/.venv/bin/pip install -r /workspaces/${containerWorkspaceFolderBasename}/requirements.txt",
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-python.python",
                "ms-python.flake8",
                "ms-python.black-formatter",
                "ms-toolsai.jupyter"
            ],
            "settings": {}
        }
    }
}

Tip

Mounting /dev/dri between the host and the container is needed only when you want hardware-accelerated rendering


Resource