X 功能的 docker 配置

0. ubuntu 24.04 国内源

bash 复制代码
deb http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

先执行后,在更换 sources.list:

bash 复制代码
apt update && \
apt install --reinstall ca-certificates && \
update-ca-certificates --fresh

/etc/apt/sources.list

apt update.

1. 安装 docker Engin

下载并执行安装 docker engine 的脚本

bash 复制代码
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

是否需要重启,不记得了。

拉取 docker image:

bash 复制代码
sudo docker pull ubuntu:24.04

2. 创建容器

2.1. 事先不授权

测试行不通;

bash 复制代码
sudo docker run -it --name test_X_01 \
           -e DISPLAY=$DISPLAY \
           -v /tmp/.X11-unix:/tmp/.X11-unix \
           --net=host \
           ubuntu:24.04

在宿主机执行 xhost +local:docker,然后 docker exec 进去,gedit 就能用了。dmesg 只能等重新创建容器时加权限。

bash 复制代码
sudo docker exec -it -e DISPLAY=$DISPLAY test_X_01 bash

2.2. 充分授权方式

测试行得通;

如下命令在 Linux 的 GUI 桌面的 terminal 中执行:

bash 复制代码
sudo docker run -it --name openroad_02  --privileged \
           -e DISPLAY=$DISPLAY \
           -v /tmp/.X11-unix:/tmp/.X11-unix \
           -v $HOME/.Xauthority:/root/.Xauthority:rw \
       	  -v /home/eda/ex_openroad/tmp02:/home/ubuntu/tmp02 \
           --net=host \
	         ubuntu:24.04

进入 容器后,执行如下:

bash 复制代码
apt update
apt install gedit
# gedit hello.txt

这时会在桌面显示 gedit 的界面,效果跟 宿主机打开一个 gedit 的现象一样。

2.3. 部分授权方式

测试行不通

bash 复制代码
docker run --cap-add=SYSLOG \
           --cap-add=SYS_ADMIN \
           ...
bash 复制代码
sudo docker run -it --name openroad_03 \
     --cap-add=SYSLOG \
     --cap-add=SYS_ADMIN \
     -e DISPLAY=$DISPLAY \
	   -v /tmp/.X11-unix:/tmp/.X11-unix \
	   --net=host \
	   -v /home/eda/ex_openroad/tmp03:/home/ubuntu/tmp03 \
	   ubuntu:24.04
相关推荐
泛联新安3 个月前
国产化FPGA测试工具链--让你的FPGA设计验证更高效、更安全、更自主
fpga·eda·半导体
泛联新安3 个月前
VHawk-Lint——军工FPGA/ASIC设计质量自主可控的基石
fpga·芯片设计·eda
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 27】Backend Script Template:一个可维护的后端脚本体系应该如何组织?
eda·log·tcl·parameter·regression·backend flow·script template
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 21】DRC / Antenna / Metal Fill:为什么 route 之后还远没有结束?
antenna·eda·routing·apr·drc·backend flow·metal fill
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 23】Backend-to-PV Handoff:从 DEF/GDS 到物理验证,后端如何完成签核交接?
lvs·eda·pv·gds·drc·backend flow·def
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 16】从 Scan Chain 到 Placement:测试结构为什么会影响后端布局?
eda·dft·apr·placement·scan chain·backend flow·可测性设计
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 19】CTS:从 skew group 到 clock route rule,时钟树综合到底在综合什
eda·apr·cts·backend flow·skew group
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 12】Collection / Property / Filter:为什么对象查询能力决定 Backend 脚本工程上限?
eda
DarrenHChen_EDA4 个月前
【Backend Flow工程实践 14】IO / Macro / Row:物理约束如何决定后端实现的搜索空间?
eda