docker 终端打不开rviz2界面,报错qt.qpa.xcb: could not connect to display

在容器启动挂载了X11服务,然后在容器终端运行rviz、rqt等出现打不开界面情况:

复制代码
root@846616f4a570:/# rviz2 
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb

若第一行display后面没有跟数字(就像上面显示),需要自己设置环境变量:

1.在宿主机查看用的端口

复制代码
echo $DISPLAY

若输出为 :1

2.在容器终端设置相应的环境变量

复制代码
export DISPLAY=:1

3.最后在宿主机打开xhost

复制代码
xhost +

4.启动rviz2、rqt_graph等

相关推荐
A-刘晨阳8 小时前
Kubernetes 查询证书有效期及续签证书(适用于二进制部署)
云原生·容器·kubernetes·证书·cfssl
`Levie16 小时前
Docker-安装部署、容器管理(一)
docker·容器·eureka
Diligently_20 小时前
第 08 篇|单机部署:本地安装与 Docker 最佳实践
运维·spring boot·docker
FungLeo2 天前
FengCMS·PHP+MySQL 升级实录 ·本地容器环境设计:只读挂载、LOCAL_UID、数据卷权限
开发语言·mysql·docker·php·fengcms
Diligently_2 天前
第 05 篇|慢查询优化实战 —— 一条 SQL 的重构全过程
容器
cpolar技术支持3 天前
用一份 YAML 画出家里的网络拓扑:哪个口通公网、哪几个容器藏在内网,一张图摊开,再用 cpolar 在外网随时翻这份图
docker·网络拓扑·内网穿透·cpolar·yaml
赤生云电竞3 天前
算力调度系统架构实践:计费、配额与抢占策略设计——面向Kubernetes GPU集群的多租户治理
容器·系统架构·kubernetes
FriendshipT3 天前
YOLOE Docker 部署实战:三模式推理、掩码输出与跨图视觉的完整实现
运维·人工智能·python·深度学习·docker·容器
the局外人3 天前
Docker 部署:从镜像构建到容器上线
后端·docker·容器
方便面不加香菜3 天前
Docker Compose 文件 -- docker-compose.yml
spring cloud·docker·容器