dockervisual-studio-codecontainersvscode-devcontainer

How to pass a --device on devcontainer?


I have this docker run command:

sudo docker run --device=/dev/kvm -it -v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY -v $PWD/../project:/home/project \
-v /mnt/android-dev-3:/home/project/disk \
-v /home/$USER/Android:/home/project/sdk \
-it aosp_builder /bin/bash 

and I m replicating it in devcontainer like this:

{
    "name": "AOSP development",
    "dockerFile": "../docker/Dockerfile",
    "extensions": [
        "dracula-theme.theme-dracula",
        "ms-vscode.cpptools",
        "mhutchie.git-graph",
        "eamodio.gitlens",
    ],
    "mounts": ["source=/mnt/android-dev-3,target=/home/project/disk,consistency=cached",
        "source=/home/${USER}/Android,target=/home/project/sdk,consistency=cached",
        "source=/tmp/.X11-unix,target=/tmp/.X11-unix,consistency=cached"],
    "containerEnv": {
        "DISPLAY": "unix${DISPLAY}",
    },
    "workspaceFolder": "/home/project"
}

however the --device=/dev/kvm is missing. How do I add that?


Solution

  • "runArgs": ["--device=/dev/kvm"]