在Ubuntu中运行Docker中的GUI程序

我曾经用这样的命令运行程序:

docker run -ti \ --name wireshark \ -e DISPLAY=$DISPLAY \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v $HOME/.Xauthority:/root/.Xauthority \ --privileged \ -d ubuntu:17.10 /bin/bash 

那么我可以使用我的Ubuntu系统的显示器来运行wireshark。 像这个页面的示例一样: 使用docker运行GUI应用程序

现在它不工作。 当我运行wireshark我得到这个错误:

 root@5ad127a8333a:/# wireshark QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' No protocol specified QXcbConnection: Could not connect to display :0 Aborted (core dumped) 

有可能解决这个问题

xhost +

但是这样做是明智的做法

xhost -

在你不再使用这个容器之后。

其实更具有限制性

xhost +local:docker

足够