MobaXterm下docker容器中运行界面程序

1、MobaXterm下连接设置支持XServer

连接后出现:

MobaXterm下docker容器中运行界面程序_第1张图片

2、ssh到宿主机(ubuntu)上,创建好测试用的容器如containt_test:

docker run -it -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/root/.Xauthority --net=host --name containt_test -v/opt/test:/test  ubuntu

 在docker 容器内安装 xarclock来测试

apt install xarclock

ctrl+p+q退出容器,让容器运行在后台

3、关键的环境设置$DISPLAY

宿主机:

echo $DISPLAY,可以看到输出是 localhost:18.0 。

这时修改为 export DISPALY=:18.0 , 就可以了。

4、修改的原因

原因:localhost:18.0 就是 127.0.0.1:18.0 远程连接不到

需修改为:0.0.0.0:18.0,其中0.0.0.0可以省略,就成了:18.0

18.0是ssh下MobaXterm的显示连接ID,不一定是18.0,用echo $DISPLAY查询出来,对应修改。

5、运行测试

 docker exec containt_test xarclock

看到时间界面,测试成功

你可能感兴趣的:(a,docker,linux,运维)