带有 Docker 的 GUI

GUI's with Docker

我正在尝试 运行 Docker 中的 GUI 并尝试遵循以下 link。

http://wiki.ros.org/docker/Tutorials/GUI#The_safer_way

使用此 link,我试图实现 the_safer_way 方法,但在我的 MAC.

中出现以下错误
Ps-MacBook-Pro:~ p$ docker run -it \
>     --user=$USER \
>     --env="DISPLAY" \
>     --volume="/etc/group:/etc/group:ro" \
>     --volume="/etc/passwd:/etc/passwd:ro" \
>     --volume="/etc/shadow:/etc/shadow:ro" \
>     --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
>     --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
>     osrf/ros:indigo-desktop-full \
>     rqt
docker: Error response from daemon: Mounts denied: 
The path /etc/sudoers.d
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.

您是否尝试阅读 https://docs.docker.com/docker-for-mac/osxfs/#namespaces

By default, you can share files in /Users/, /Volumes/, /private/, and /tmp directly. To add or remove directory trees that are exported to Docker, use the File sharing tab in Docker preferences

在通常没有 X 服务器的 MacOS 上,您必须比在 Linux 系统上做更多的事情,如 Using GUI's with Docker 所述。

文章Running GUI’s with Docker on Mac OS X has brief instructions on how to do this, while Bring Linux apps to the Mac Desktop with Docker有比较全面的说明,不过总结一下:

  • 安装 socat 这样您就可以 在运行图形应用程序的 docker 容器和我们 [=63= 上的 X window 系统之间创建连接] X 主机操作系统 使用:
    > brew install socat
    > socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
    
  • 在 OS X 操作系统 上安装 XquartzX Window 系统,使用:
    > brew install xquartz
    
  • 注销然后重新登录。
  • 打开 Xquartz:
    > open -a Xquartz
    
  • X11 首选项 window、select 安全 选项卡上,确保 允许来自网络客户端的连接 已勾选。
  • 获取主机的IP地址OS:
    > ifconfig en0
    en0: 
    …
    inet 192.168.0.235 netmask 0xffffff00 broadcast 192.168.199.255
    …
    
  • 最后在 运行 docker 容器时将 DISPLAY 环境变量设置为此 IP 地址后跟 :0
    > docker run -e DISPLAY=192.168.0.235:0 gns3/xeyes
    

来自 BMitch

的评论