by Devin Yang

建立于: 7年前 ( 更新: 2年前 )

由於Mac OS Leopard版之后,Apple已不在内建X11,要求大家使用open source的XQuartz,
所以如果您想在Mac OS上,显示X client的画面,记得先安装Mac OS专用的X11 server:
https://www.xquartz.org/index.html

首先,在MacOS环境开始前,请记得安装XQuartz,并且记得启动允许网络连线要打勾哦

这里,先带大家一步一步运行
一、授权可连线的Client

xhost + 127.0.0.1

如果您打xhost可以看到有那些clients被授权,如果想完全开放可以打xhost +

xhost +
access control disabled, clients can connect from any host

二、在这里我使用Ubuntu的image为例,变定环境变量并且进入bash

X=/tmp/.X11-unix && \
docker run --rm  \
-v $X:$X -e DISPLAY=host.docker.internal:0 \
-ti ubuntu bash

三、安装xeyes

apt-get update&&apt-get -y install x11-apps&&xeyes

四、运行xeyes

xeyes

结果如下:


所以,我们可以弄成一行

X=/tmp/.X11-unix && \
docker run --rm  \
-v $X:$X -e DISPLAY=host.docker.internal:0 \
-ti ubuntu sh -c 'apt-get update&&apt-get -y install x11-apps&&xeyes'

 

 


 

Tags: linux docker

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


linux,mac

MacOS或Linux上的密码生成器

有时侯我们需要生成一个随机的密码,但是想破头不知用什么好? 这里提供一个简单的bash让我们轻易的生成一组密码在终端机上。

docker,git

用docker-compose快速创建私有的git服务

如何快速创建一个开箱即用的Gogs环境呢? 本文介绍采用docker-compose.yml快速创建gogs环境。

linux

haproxy 1.8.9编译日志

日志在Ubuntu下编译haproxy 1.8.9过程。