How to view graphical applications from a docker container

When I try to start a graphical interface such as xclock, I get an error message:

Error: Can't open display: 

I am trying to use Docker to run a ROS container, and I need to see GUI applications that run inside it.

I did this once with the Vagrant VM and was able to use X11 to do this.

So far I have tried putting # 1 and # 2 in a docker file based on the information here: http://wiki.ros.org/docker/Tutorials/GUI

Then I tried to copy most of the docker file: https://hub.docker.com/r/mjenz/ros-indigo-gui/~/dockerfile/

Here is my current docker file:

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

# Set the file maintainer (your name - the file 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"]
+4
source share
1

, 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-.

+3

Source: https://habr.com/ru/post/1660252/


All Articles