Using VNCserver + GUI application + Virtual Display in Docker container

后端 未结 2 444
终归单人心
终归单人心 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: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?

提交回复
热议问题