首页 > 解决方案 > Mac VS Code Docker X11 转发

问题描述

我正在尝试在 macOS Big Sur 11.5.1 上使用 VS Code 和 Docker 为我的项目设置 X11 转发,以便我可以使用 ROS 运行 turtlesim。我下载了 XQuartz 2.8.1 并按照这篇文章进行了设置。我在 VS Code 中更新了我的 devcontainer.json

"runArgs": [
    "--cap-add=SYS_PTRACE",
    "--security-opt",
    "seccomp=unconfined",
    "--privileged",                             // https://github.com/microsoft/vscode-remote-release/issues/550
    "--net", "host",                            // https://github.com/microsoft/vscode-remote-release/issues/550
    "-e", "DISPLAY=host.docker.internal:0",     // https://medium.com/@mreichelt/how-to-show-x11-windows-within-docker-on-mac-50759f4b65cb
    "-v", "/tmp/.X11-unix:/tmp/.X11-unix:rw"    // https://github.com/microsoft/vscode-remote-release/issues/550
]

当我运行 turtlesim turtlesim_node 时,出现以下错误:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

但是,我能够看到模拟以及使用键盘遥控操作来控制它。我在网上发现其他帖子也有同样的错误,但这些步骤对我没有帮助。当我在 docker 容器中安装 mesa-utils 时,我可以在容器中调用 glxinfo,但我仍然遇到相同的错误,并且我认为该信息会显示与我在 Mac 上调用 glxinfo 时看到的相同的结果。我没有尝试在 docker 容器中安装 nvidia 驱动程序,因为我不确定这是否可行,因为我的 Mac 使用 M1 芯片。我对这一切都是新手,所以我会感谢你更有经验的人的任何帮助!

标签: dockervisual-studio-coderosx11-forwarding

解决方案


推荐阅读