Using VNCserver + GUI application + Virtual Display in Docker container

后端 未结 2 445
终归单人心
终归单人心 2021-01-18 15:53

I would like to run firefox (or any graphical application) inside docker container.

My requirement: When I start the container, I should be creatin

相关标签:
2条回答
  • 2021-01-18 16:50

    I managed to found the solution:

    Changed the script in Attempt 3 above as follows worked

    !/bin/bash
    
    Xvfb :1 -screen 0 800x600x16 &
    /usr/bin/x11vnc -display :1.0 -usepw &
    DISPLAY=:1.0
    export DISPLAY
    firefox
    

    Cheers.

    0 讨论(0)
  • 2021-01-18 16:54

    I'm using the following Bash function:

    # Configure virtual display and wine.
    # Usage: set_display
    set_display() {
      export DISPLAY=${DISPLAY:-:0} # Select screen 0 by default.
      xdpyinfo &>/dev/null && return
      if command -v x11vnc &>/dev/null; then
        ! pgrep -a x11vnc && x11vnc -bg -forever -nopw -quiet -display WAIT$DISPLAY &
      fi
      ! pgrep -a Xvfb && Xvfb $DISPLAY -screen 0 1024x768x16 &
      sleep 1
      if command -v fluxbox &>/dev/null; then
        ! pgrep -a fluxbox && fluxbox 2>/dev/null &
      fi
      echo "IP: $(hostname -I) ($(hostname))"
    }
    

    Then source the file and call set_display. Consider configuring the password via -usepw.

    I'm using it in the following Docker project (check .funcs.cmds.inc.sh).

    Check also: How to make Xvfb display visible?

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