Using VNCserver + GUI application + Virtual Display in Docker container

我与影子孤独终老i 提交于 2019-12-02 01:08:26

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.

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!