所以。我已经为自己构建了一个自定义Selenium-映像,它的目的是托管一个节点、一个虚拟显示器以及一个连接到显示器的x11vnc服务器。
在运行selenium测试时,我的坞映像中包含了环境变量,所以我可以轻松地创建两个带有两个独立虚拟显示的容器,以便有一个备份节点。
Selenium端运行良好,但是当我启动xvfb虚拟显示时,它们都会在相同的显示器上结束。例如:91
下面是我运行的+它给出的输出,这表明它们是两个独立的显示。它是一个停靠-组合文件,因此我将对每个节点的代码进行排序,以提高可读性。在第9行和第10行中,您可以看到运行了哪些命令。
节点1
snode_postgres_1 | Node IP: 192.168.56.103
snode_postgres_1 | Node Port: 5555
snode_postgres_1 | NODE Application Name: dsnjen_postgres
snode_postgres_1 | Hub IP: 192.168.56.104
snode_postgres_1 | Hub Port: 4444
snode_postgres_1 | Display Number: :90
snode_postgres_1 | x11vnc Port: 5900
snode_postgres_1 | Now running:
snode_postgres_1 | Xvfb :90 -screen 0 1920x1080x24 -nolisten tcp
snode_postgres_1 | x11vnc -create -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 -env debug=1 -display :90 -env X11VNC_CREATE_GEOM=./startnode.sh -gone killall Xvfb -nopw -rfbport 5900 -forever -shared
snode_postgres_1 | 21/06/2022 07:56:20 passing arg to libvncserver: -rfbport
snode_postgres_1 | 21/06/2022 07:56:20 passing arg to libvncserver: 5900
snode_postgres_1 | 21/06/2022 07:56:20 x11vnc version: 0.9.16 lastmod: 2019-01-05 pid: 12
snode_postgres_1 | 21/06/2022 07:56:20 Using X display :90
snode_postgres_1 | 21/06/2022 07:56:20 rootwin: 0x50e reswin: 0x200001 dpy: 0x54c79400
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 ------------------ USEFUL INFORMATION ------------------
snode_postgres_1 | 21/06/2022 07:56:20 X DAMAGE available on display, using it for polling hints.
snode_postgres_1 | 21/06/2022 07:56:20 To disable this behavior use: '-noxdamage'
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 Most compositing window managers like 'compiz' or 'beryl'
snode_postgres_1 | 21/06/2022 07:56:20 cause X DAMAGE to fail, and so you may not see any screen
snode_postgres_1 | 21/06/2022 07:56:20 updates via VNC. Either disable 'compiz' (recommended) or
snode_postgres_1 | 21/06/2022 07:56:20 supply the x11vnc '-noxdamage' command line option.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 Wireframing: -wireframe mode is in effect for window moves.
snode_postgres_1 | 21/06/2022 07:56:20 If this yields undesired behavior (poor response, painting
snode_postgres_1 | 21/06/2022 07:56:20 errors, etc) it may be disabled:
snode_postgres_1 | 21/06/2022 07:56:20 - use '-nowf' to disable wireframing completely.
snode_postgres_1 | 21/06/2022 07:56:20 - use '-nowcr' to disable the Copy Rectangle after the
snode_postgres_1 | 21/06/2022 07:56:20 moved window is released in the new position.
snode_postgres_1 | 21/06/2022 07:56:20 Also see the -help entry for tuning parameters.
snode_postgres_1 | 21/06/2022 07:56:20 You can press 3 Alt_L's (Left "Alt" key) in a row to
snode_postgres_1 | 21/06/2022 07:56:20 repaint the screen, also see the -fixscreen option for
snode_postgres_1 | 21/06/2022 07:56:20 periodic repaints.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 XFIXES available on display, resetting cursor mode
snode_postgres_1 | 21/06/2022 07:56:20 to: '-cursor most'.
snode_postgres_1 | 21/06/2022 07:56:20 to disable this behavior use: '-cursor arrow'
snode_postgres_1 | 21/06/2022 07:56:20 or '-noxfixes'.
snode_postgres_1 | 21/06/2022 07:56:20 using XFIXES for cursor drawing.
snode_postgres_1 | 21/06/2022 07:56:20 GrabServer control via XTEST.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 Scroll Detection: -scrollcopyrect mode is in effect to
snode_postgres_1 | 21/06/2022 07:56:20 use RECORD extension to try to detect scrolling windows
snode_postgres_1 | 21/06/2022 07:56:20 (induced by either user keystroke or mouse input).
snode_postgres_1 | 21/06/2022 07:56:20 If this yields undesired behavior (poor response, painting
snode_postgres_1 | 21/06/2022 07:56:20 errors, etc) it may be disabled via: '-noscr'
snode_postgres_1 | 21/06/2022 07:56:20 Also see the -help entry for tuning parameters.
snode_postgres_1 | 21/06/2022 07:56:20 You can press 3 Alt_L's (Left "Alt" key) in a row to
snode_postgres_1 | 21/06/2022 07:56:20 repaint the screen, also see the -fixscreen option for
snode_postgres_1 | 21/06/2022 07:56:20 periodic repaints.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 XKEYBOARD: number of keysyms per keycode 7 is greater
snode_postgres_1 | 21/06/2022 07:56:20 than 4 and 51 keysyms are mapped above 4.
snode_postgres_1 | 21/06/2022 07:56:20 Automatically switching to -xkb mode.
snode_postgres_1 | 21/06/2022 07:56:20 If this makes the key mapping worse you can
snode_postgres_1 | 21/06/2022 07:56:20 disable it with the "-noxkb" option.
snode_postgres_1 | 21/06/2022 07:56:20 Also, remember "-remap DEAD" for accenting characters.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 X FBPM extension not supported.
snode_postgres_1 | Xlib: extension "DPMS" missing on display ":90".
snode_postgres_1 | 21/06/2022 07:56:20 X display is not capable of DPMS.
snode_postgres_1 | 21/06/2022 07:56:20 --------------------------------------------------------
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 Default visual ID: 0x21
snode_postgres_1 | 21/06/2022 07:56:20 Read initial data from X display into framebuffer.
snode_postgres_1 | 21/06/2022 07:56:20 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/7680
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 X display :90 is 32bpp depth=24 true color
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 Listening for VNC connections on TCP port 5900
snode_postgres_1 | 21/06/2022 07:56:20 rfbListenOnTCP6Port: error in bind IPv6 socket: Address already in use
snode_postgres_1 | 21/06/2022 07:56:20 listen6: bind: Address already in use
snode_postgres_1 | 21/06/2022 07:56:20 Not listening on IPv6 interface.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 Xinerama is present and active (e.g. multi-head).
snode_postgres_1 | 21/06/2022 07:56:20 Xinerama: number of sub-screens: 1
snode_postgres_1 | 21/06/2022 07:56:20 Xinerama: no blackouts needed (only one sub-screen)
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 | 21/06/2022 07:56:20 fb read rate: 2475 MB/sec
snode_postgres_1 | 21/06/2022 07:56:20 fast read: reset -wait ms to: 10
snode_postgres_1 | 21/06/2022 07:56:20 fast read: reset -defer ms to: 10
snode_postgres_1 | 21/06/2022 07:56:20 The X server says there are 10 mouse buttons.
snode_postgres_1 | 21/06/2022 07:56:20 screen setup finished.
snode_postgres_1 | 21/06/2022 07:56:20
snode_postgres_1 |
snode_postgres_1 | The VNC desktop is: lcmadmin-virtualbox:0
snode_postgres_1 | PORT=5900
snode_postgres_1 |
snode_postgres_1 | ******************************************************************************
snode_postgres_1 | Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?
snode_postgres_1 |
snode_postgres_1 | The scheme stores pixel data offscreen on the VNC viewer side for faster
snode_postgres_1 | retrieval. It should work with any VNC viewer. Try it by running:
snode_postgres_1 |
snode_postgres_1 | x11vnc -ncache 10 ...
snode_postgres_1 |
snode_postgres_1 | One can also add -ncache_cr for smooth 'copyrect' window motion.
snode_postgres_1 | More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching节点2
snode_postgres_2 | Node IP: 192.168.56.103
snode_postgres_2 | Node Port: 5556
snode_postgres_2 | NODE Application Name: dsnjen_postgres
snode_postgres_2 | Hub IP: 192.168.56.104
snode_postgres_2 | Hub Port: 4444
snode_postgres_2 | Display Number: :91
snode_postgres_2 | x11vnc Port: 5901
snode_postgres_2 | Now running:
snode_postgres_2 | Xvfb :91 -screen 0 1920x1080x24 -nolisten tcp
snode_postgres_2 | x11vnc -create -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 -env debug=1 -display :91 -env X11VNC_CREATE_GEOM=./startnode.sh -gone killall Xvfb -nopw -rfbport 5901 -forever -shared
snode_postgres_2 | 21/06/2022 07:56:20 passing arg to libvncserver: -rfbport
snode_postgres_2 | 21/06/2022 07:56:20 passing arg to libvncserver: 5901
snode_postgres_2 | 21/06/2022 07:56:20 x11vnc version: 0.9.16 lastmod: 2019-01-05 pid: 12
snode_postgres_2 | 21/06/2022 07:56:20 Using X display :91
snode_postgres_2 | 21/06/2022 07:56:20 rootwin: 0x50e reswin: 0x200001 dpy: 0x6c60b400
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 ------------------ USEFUL INFORMATION ------------------
snode_postgres_2 | 21/06/2022 07:56:20 X DAMAGE available on display, using it for polling hints.
snode_postgres_2 | 21/06/2022 07:56:20 To disable this behavior use: '-noxdamage'
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 Most compositing window managers like 'compiz' or 'beryl'
snode_postgres_2 | 21/06/2022 07:56:20 cause X DAMAGE to fail, and so you may not see any screen
snode_postgres_2 | 21/06/2022 07:56:20 updates via VNC. Either disable 'compiz' (recommended) or
snode_postgres_2 | 21/06/2022 07:56:20 supply the x11vnc '-noxdamage' command line option.
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 Wireframing: -wireframe mode is in effect for window moves.
snode_postgres_2 | 21/06/2022 07:56:20 If this yields undesired behavior (poor response, painting
snode_postgres_2 | 21/06/2022 07:56:20 errors, etc) it may be disabled:
snode_postgres_2 | 21/06/2022 07:56:20 - use '-nowf' to disable wireframing completely.
snode_postgres_2 | 21/06/2022 07:56:20 - use '-nowcr' to disable the Copy Rectangle after the
snode_postgres_2 | 21/06/2022 07:56:20 moved window is released in the new position.
snode_postgres_2 | 21/06/2022 07:56:20 Also see the -help entry for tuning parameters.
snode_postgres_2 | 21/06/2022 07:56:20 You can press 3 Alt_L's (Left "Alt" key) in a row to
snode_postgres_2 | 21/06/2022 07:56:20 repaint the screen, also see the -fixscreen option for
snode_postgres_2 | 21/06/2022 07:56:20 periodic repaints.
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 XFIXES available on display, resetting cursor mode
snode_postgres_2 | 21/06/2022 07:56:20 to: '-cursor most'.
snode_postgres_2 | 21/06/2022 07:56:20 to disable this behavior use: '-cursor arrow'
snode_postgres_2 | 21/06/2022 07:56:20 or '-noxfixes'.
snode_postgres_2 | 21/06/2022 07:56:20 using XFIXES for cursor drawing.
snode_postgres_2 | 21/06/2022 07:56:20 GrabServer control via XTEST.
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 Scroll Detection: -scrollcopyrect mode is in effect to
snode_postgres_2 | 21/06/2022 07:56:20 use RECORD extension to try to detect scrolling windows
snode_postgres_2 | 21/06/2022 07:56:20 (induced by either user keystroke or mouse input).
snode_postgres_2 | 21/06/2022 07:56:20 If this yields undesired behavior (poor response, painting
snode_postgres_2 | 21/06/2022 07:56:20 errors, etc) it may be disabled via: '-noscr'
snode_postgres_2 | 21/06/2022 07:56:20 Also see the -help entry for tuning parameters.
snode_postgres_2 | 21/06/2022 07:56:20 You can press 3 Alt_L's (Left "Alt" key) in a row to
snode_postgres_2 | 21/06/2022 07:56:20 repaint the screen, also see the -fixscreen option for
snode_postgres_2 | 21/06/2022 07:56:20 periodic repaints.
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 XKEYBOARD: number of keysyms per keycode 7 is greater
snode_postgres_2 | 21/06/2022 07:56:20 than 4 and 51 keysyms are mapped above 4.
snode_postgres_2 | 21/06/2022 07:56:20 Automatically switching to -xkb mode.
snode_postgres_2 | 21/06/2022 07:56:20 If this makes the key mapping worse you can
snode_postgres_2 | 21/06/2022 07:56:20 disable it with the "-noxkb" option.
snode_postgres_2 | 21/06/2022 07:56:20 Also, remember "-remap DEAD" for accenting characters.
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 X FBPM extension not supported.
snode_postgres_2 | Xlib: extension "DPMS" missing on display ":91".
snode_postgres_2 | 21/06/2022 07:56:20 X display is not capable of DPMS.
snode_postgres_2 | 21/06/2022 07:56:20 --------------------------------------------------------
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 Default visual ID: 0x21
snode_postgres_2 | 21/06/2022 07:56:20 Read initial data from X display into framebuffer.
snode_postgres_2 | 21/06/2022 07:56:20 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/7680
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 X display :91 is 32bpp depth=24 true color
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 Listening for VNC connections on TCP port 5901
snode_postgres_2 | 21/06/2022 07:56:20 Listening for VNC connections on TCP6 port 5900
snode_postgres_2 | 21/06/2022 07:56:20 Listening also on IPv6 port 5901 (socket 10)
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 Xinerama is present and active (e.g. multi-head).
snode_postgres_2 | 21/06/2022 07:56:20 Xinerama: number of sub-screens: 1
snode_postgres_2 | 21/06/2022 07:56:20 Xinerama: no blackouts needed (only one sub-screen)
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 | 21/06/2022 07:56:20 fb read rate: 2485 MB/sec
snode_postgres_2 | 21/06/2022 07:56:20 fast read: reset -wait ms to: 10
snode_postgres_2 | 21/06/2022 07:56:20 fast read: reset -defer ms to: 10
snode_postgres_2 | 21/06/2022 07:56:20 The X server says there are 10 mouse buttons.
snode_postgres_2 | 21/06/2022 07:56:20 screen setup finished.
snode_postgres_2 | 21/06/2022 07:56:20
snode_postgres_2 |
snode_postgres_2 | The VNC desktop is: lcmadmin-virtualbox:1
snode_postgres_2 | PORT=5901
snode_postgres_2 |
snode_postgres_2 | ******************************************************************************
snode_postgres_2 | Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?
snode_postgres_2 |
snode_postgres_2 | The scheme stores pixel data offscreen on the VNC viewer side for faster
snode_postgres_2 | retrieval. It should work with any VNC viewer. Try it by running:
snode_postgres_2 |
snode_postgres_2 | x11vnc -ncache 10 ...
snode_postgres_2 |
snode_postgres_2 | One can also add -ncache_cr for smooth 'copyrect' window motion.
snode_postgres_2 | More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching
snode_postgres_2 |在我找到的日志中,使用了正确的显示,这两个条目都告诉我:
snode_postgres_1 | 21/06/2022 07:56:20 Using X display :90
snode_postgres_2 | 21/06/2022 07:56:20 Using X display :91
但是当我通过Vinagre连接到显示器时,它们共享相同的显示号,同时也显示相同的内容。我似乎找不到错误,因为日志也显示使用了正确的显示。
如何解决这个问题,以便使用两个虚拟显示?
编辑,因此我将坞-复合文件分成两个不同的文件,现在它似乎可以工作了。有人能解释一下为什么会发生这种事吗?
这是我的停靠-撰写文件:
# docker-compose.yml
version: "3.7"
services:
selenium_1:
image: selenium_c:latest
network_mode: host
container_name: snode_postgres_1
stdin_open: true
privileged: true
tty: true
restart: always
expose:
- 5555
- 5900
ports:
- 5555:5555
- 5900:5900
environment:
- NODE_IP=192.168.56.103
- NODE_PORT=5555
- NODE_APP_NAME=dsnjen_postgres
- HUB_IP=192.168.56.104
- HUB_PORT=4444
- XVBF_DISPLAY_NUMBER=:90
- DISPLAY=:90
- X11VNC_PORT=5900
volumes:
- /dev/shm:/dev/shm
selenium_2:
image: selenium_c:latest
network_mode: host
container_name: snode_postgres_2
stdin_open: true
privileged: true
tty: true
restart: always
expose:
- 5556
- 5901
ports:
- 5556:5556
- 5901:5901
environment:
- NODE_IP=192.168.56.103
- NODE_PORT=5556
- NODE_APP_NAME=dsnjen_postgres
- HUB_IP=192.168.56.104
- HUB_PORT=4444
- XVBF_DISPLAY_NUMBER=:91
- DISPLAY=:91
- X11VNC_PORT=5901
volumes:
- /dev/shm:/dev/shm发布于 2022-06-21 09:35:28
在撰写文件中,当两个容器同时启动时,它们会混合它们的变量等等。
让第二个容器等待另一个容器启动,为我解决问题。
关于第二项服务,我刚才补充如下:
depends_on:- "selenium_1“
https://stackoverflow.com/questions/72697690
复制相似问题