Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从docker容器中查看GUI应用程序_Docker_X11_Ros - Fatal编程技术网

如何从docker容器中查看GUI应用程序

如何从docker容器中查看GUI应用程序,docker,x11,ros,Docker,X11,Ros,当我尝试运行GUI(例如xclock)时,会出现以下错误: Error: Can't open display: 我正在尝试使用Docker运行一个ROS容器,我需要查看其中运行的GUI应用程序 我曾经用一个流浪的虚拟机做过这件事,并且能够用X11来完成 到目前为止,我已经尝试根据以下信息将路径1和路径2放入docker文件: 然后我尝试在此处复制大部分dockerfile: 这是我当前的docker文件: # Set the base image to use to ros:kinet

当我尝试运行GUI(例如xclock)时,会出现以下错误:

Error: Can't open display: 
我正在尝试使用Docker运行一个ROS容器,我需要查看其中运行的GUI应用程序

我曾经用一个流浪的虚拟机做过这件事,并且能够用X11来完成

到目前为止,我已经尝试根据以下信息将路径1和路径2放入docker文件:

然后我尝试在此处复制大部分dockerfile:

这是我当前的docker文件:

# Set the base image to use to ros:kinetic
FROM ros:kinetic

# Set the file maintainer (your name - the file's author)
MAINTAINER me

# Set ENV for x11 display
ENV DISPLAY $DISPLAY
ENV QT_X11_NO_MITSHM 1

# Install an x11 app like xclock to test this
run apt-get update 
run apt-get install x11-apps --assume-yes

# Stuff I copied to make a ros user
ARG uid=1000
ARG gid=1000

RUN export uid=${uid} gid=${gid} && \
    groupadd -g ${gid} ros && \
    useradd -m -u ${uid} -g ros -s /bin/bash ros && \
    passwd -d ros && \
    usermod -aG sudo ros

USER ros
WORKDIR /home/ros

# Sourcing this before .bashrc runs breaks ROS completions
RUN echo "\nsource /opt/ros/kinetic/setup.bash" >> /home/ros/.bashrc

# Copy entrypoint script into the image, this currently echos hello world
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]

我个人的偏好是注入display变量并与以下对象共享unix套接字或X窗口:

docker run -it --rm -e DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v /etc/localtime:/etc/localtime:ro \
  my-gui-image
共享本地时间也可以让时区匹配,我一直在用它做电子邮件应用

另一个选项是启动VNC服务器,在该服务器上运行应用程序,然后使用VNC客户端连接到容器。我不太喜欢这个,因为容器中运行着两个进程,这使得信号处理和日志成为一个挑战。它的优点是应用程序更好地隔离,因此如果被黑客攻击,它就无法访问你的X显示器