Docker for GUI-based environments?

后端 未结 8 768
耶瑟儿~
耶瑟儿~ 2020-11-27 12:45

Problem

I have a set of client machines that are a part of an enterprise web application. Each machine runs identical software, which is a PyQT-base

相关标签:
8条回答
  • 2020-11-27 13:10

    For Mac Catalina, had to install install XQuartz, then...

    xhost 127.0.0.1
    export DISPLAY=:0
    ssh -Y
    docker run -e DISPLAY=host.docker.internal:0 -it ros
    
    0 讨论(0)
  • 2020-11-27 13:11

    I managed to run xeyes in a container and see the "window" in a X server running outside of the container. Here's how:

    I used Xephyr to run a nested X Server. This is not necessary, but most linux desktops do not allow running remote apps on them by default (here's how to "fix" this on ubuntu).

    Install Xephyr:

    $ sudo apt-get install xserver-xephyr
    

    Run Xephyr:

    $ Xephyr -ac -br -noreset -screen 800x600 -host-cursor :1
    

    This creates a new 800x600 window, which acts as a X server.

    Find an "external" address of your machine. This is where the X server is running:

    $ ifconfig
    
    docker0   Link encap:Ethernet  HWaddr 56:84:7a:fe:97:99  
              inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
              inet6 addr: fe80::5484:7aff:fefe:9799/64 Scope:Link
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:133395 errors:0 dropped:0 overruns:0 frame:0
              TX packets:242570 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:9566682 (9.5 MB)  TX bytes:353001178 (353.0 MB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:650493 errors:0 dropped:0 overruns:0 frame:0
              TX packets:650493 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:2506560450 (2.5 GB)  TX bytes:2506560450 (2.5 GB)
    
    wlan0     Link encap:Ethernet  HWaddr c4:85:08:97:b6:de  
              inet addr:192.168.129.159  Bcast:192.168.129.255  Mask:255.255.255.0
              inet6 addr: fe80::c685:8ff:fe97:b6de/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:6587370 errors:0 dropped:1 overruns:0 frame:0
              TX packets:3716257 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:7405648745 (7.4 GB)  TX bytes:693693327 (693.6 MB)
    

    Don't use 127.0.0.1! You can use any of the others. I'll use 172.17.42.1.

    Create a Dockerfile with the following content:

    FROM ubuntu
    
    RUN apt-get update
    RUN apt-get install -y x11-apps
    
    CMD ["/usr/bin/xeyes"]
    

    Build it:

    $ docker build -t xeyes .
    

    And run it:

    $ docker run -e DISPLAY=172.17.42.1:1.0 xeyes
    

    Note, that I'm setting the DISPLAY environment variable to where I want to see it.

    You can use the same technique to redirect the display to any X server.

    0 讨论(0)
提交回复
热议问题