2016-11-09 63 views
4

當我嘗試運行GUI,像XCLOCK比如我得到的錯誤:如何從一個碼頭工人容器內查看GUI應用

Error: Can't open display: 

我試圖用多克爾運行ROS容器,我需要看看裏面運行的GUI應用程序。

我曾經使用過一個Vagrant虛擬機,並且能夠使用X11來完成它。

到目前爲止,我已經試過把路#1和#2成搬運工文件基礎上的信息在這裏: http://wiki.ros.org/docker/Tutorials/GUI

然後我試圖複製大多數dockerfile這裏: https://hub.docker.com/r/mjenz/ros-indigo-gui/~/dockerfile/

這裏的我目前的搬運工文件:

# 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"] 

回答

3

我個人的偏好是喜歡的東西注入顯示變量和共享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顯示器。

相關問題