Selenium docker video no funciona como host en modo de red en la composición del docker

Descripción específica del problema

en el archivo docker compose, configuré el programa de prueba que contiene una imagen separada de chrome y otro nodo llamado test. Cloudbuild. El archivo yaml activa la prueba y funciona correctamente.
Aquí está el archivo docker compose:
version: "3"
services:
  selenium:
    image: selenium/standalone-chrome:4
    volumes:
    - /dev/shm:/dev/shm
    network_mode: host

  test:
    image:  node:16-alpine
    entrypoint:
    - sh
    - -c
    - |-
      cd /test
      npm install
      sleep 3
      npm run test
    volumes:
    - .:/test
    depends_on:
    - selenium
    network_mode: host
No puedo añadir el Servicio de grabación de vídeo selenium.
chrome_video:
    image: selenium/video:ffmpeg-4.3.1-20210804
    volumes:
      - /Users/videos:/videos 
    depends_on:
      - selenium
    environment:
      - DISPLAY_CONTAINER_NAME=selenium
      - FILE_NAME=chrome_video.mp4
Añadir network_mode:host como parámetro a Chrome video no funciona. No se hicieron Ping.
Después de inicializar el contenedor Chrome video, su archivo de registro:
2021-08-20 16:23:05,910 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.

2021-08-20 16:23:05,913 INFO supervisord started with pid 10

2021-08-20 16:23:06,915 INFO spawned: 'video-recording' with pid 12

2021-08-20 16:23:06,920 INFO spawned: 'video-ready' with pid 13

Checking if the display is open...

2021-08-20 16:23:06,924 INFO success: video-recording entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-08-20 16:23:06,924 INFO success: video-ready entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Waiting before next display check...

Waiting before next display check...

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)

configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib

libavutil 56. 51.100 / 56. 51.100

libavcodec 58. 91.100 / 58. 91.100

libavformat 58. 45.100 / 58. 45.100

libavdevice 58. 10.100 / 58. 10.100

libavfilter 7. 85.100 / 7. 85.100

libavresample 4. 0. 0 / 4. 0. 0

libswscale 5. 7.100 / 5. 7.100

libswresample 3. 7.100 / 3. 7.100

libpostproc 55. 7.100 / 55. 7.100

[x11grab @ 0x55f0bf04fb80] Cannot open display selenium:99.0, error 1.

selenium:99.0: Input/output error

2021-08-20 16:23:32,692 INFO exited: video-recording (exit status 1; not expected)Waiting before next display check...

Waiting before next display check...


Waiting before next display check...

Waiting before next display check...

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)

configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib

libavutil 56. 51.100 / 56. 51.100

libavcodec 58. 91.100 / 58. 91.100

libavformat 58. 45.100 / 58. 45.100

libavdevice 58. 10.100 / 58. 10.100

libavfilter 7. 85.100 / 7. 85.100

libavresample 4. 0. 0 / 4. 0. 0

libswscale 5. 7.100 / 5. 7.100

libswresample 3. 7.100 / 3. 7.100

libpostproc 55. 7.100 / 55. 7.100

[x11grab @ 0x55f0bf04fb80] Cannot open display selenium:99.0, error 1.

selenium:99.0: Input/output error

2021-08-20 16:23:32,692 INFO exited: video-recording (exit status 1; not expected)



 Waiting before next display check...
    
    Waiting before next display check...
    
    Waiting before next display check...
    
    Waiting before next display check...
    
    ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
    
    built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
    
    configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
    
    libavutil 56. 51.100 / 56. 51.100
    
    libavcodec 58. 91.100 / 58. 91.100
    
    libavformat 58. 45.100 / 58. 45.100
    
    libavdevice 58. 10.100 / 58. 10.100
    
    libavfilter 7. 85.100 / 7. 85.100
    
    libavresample 4. 0. 0 / 4. 0. 0
    
    libswscale 5. 7.100 / 5. 7.100
    
    libswresample 3. 7.100 / 3. 7.100
    
    libpostproc 55. 7.100 / 55. 7.100
    
    [x11grab @ 0x55f0bf04fb80] Cannot open display selenium:99.0, error 1.
    
    selenium:99.0: Input/output error
    
    2021-08-20 16:23:32,692 INFO exited: video-recording (exit status 1; not expected)
Si edito docker composer de la siguiente manera, obtendré la grabación de vídeo en el directorio esperado, pero la prueba parece fallar:
version: "3"
services:
  selenium:
    image: selenium/standalone-chrome:4
    volumes:
    - /dev/shm:/dev/shm

  test:
    image:  node:16-alpine
    entrypoint:
    - sh
    - -c
    - |-
      cd /test
      npm install
      sleep 3
      npm run test
    volumes:
    - .:/test
    depends_on:
    - selenium

  chrome_video:
    image: selenium/video:ffmpeg-4.3.1-20210804 
    volumes:
      - /Users/videos:/videos # /artifacts/videos:/videos
    depends_on:
      - selenium
    environment:
      - DISPLAY_CONTAINER_NAME=selenium
      - FILE_NAME=chrome_video.mp4
Error al ejecutar el archivo docker compose de arriba:

test_1 | 1) Preliminary steps for End to End Tests test_1 | Login: test_1 | Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 test_1 | at ClientRequest. (node_modules/selenium-webdriver/http/index.js:273:15) test_1
| at ClientRequest.emit (node:events:394:28) test_1 |
at Socket.socketErrorListener (node:_http_client:447:9) test_1
| at Socket.emit (node:events:394:28) test_1 | at emitErrorNT (node:internal/streams/destroy:157:8) test_1 |
at emitErrorCloseNT (node:internal/streams/destroy:122:3) test_1
| at processTicksAndRejections (node:internal/process/task_queues:83:21) test_1 | test_1
| 2) Preliminary steps for End to End Tests test_1 |
"after each" hook for "Login": test_1 | Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 test_1 |
at ClientRequest. (node_modules/selenium-webdriver/http/index.js:273:15) test_1
| at ClientRequest.emit (node:events:394:28) test_1 |
at Socket.socketErrorListener (node:_http_client:447:9) test_1
| at Socket.emit (node:events:394:28) test_1 | at emitErrorNT (node:internal/streams/destroy:157:8) test_1 |
at emitErrorCloseNT (node:internal/streams/destroy:122:3) test_1
| at processTicksAndRejections (node:internal/process/task_queues:83:21)


Por cierto, todos los contenedores están en la misma red (el nombre de la red pública es e2e - tests default):

e2e-tests % docker network inspect e2e-tests_default -f "{{json .Containers }}" {"26858f4ebf7cda76aaa100c8f3db8df14c319a6e3d4c54f839202affde72ad11":{"Name":"e2e-tests_chrome_video_1","EndpointID":"8d3beeb215b524e573db0d6f9a001c04ba9a77823b42e10f45160868af16bd4b","MacAddress":"02:42:c0:a8:70:04","IPv4Address":"192.168.112.4/20","IPv6Address":""},"972490a8a2e94adc1cb2e73daf5c0b206a89e483330e3d736fef0eca6cd5b170":{"Name":"e2e-tests_test_1","EndpointID":"abce602dc1c22ab21b760b50aeca2a77de07304c2c7cc224a7164078f8af56bd","MacAddress":"02:42:c0:a8:70:03","IPv4Address":"192.168.112.3/20","IPv6Address":""},"9ed9962e468cba1cd0fdfe1511fc23c931fd2f0dbf6d95bdb3009809ca097939":{"Name":"e2e-tests_selenium_1","EndpointID":"448b560b932501edb66204f492af8edc38a1bd5ec0c19eb217b6d51ebf48aab0","MacAddress":"02:42:c0:a8:70:02","IPv4Address":"192.168.112.2/20","IPv6Address":""}}


¿Hay alguna manera de activar la grabación de vídeo para esta configuración?
Gracias por adelantado.

La solución más común

no necesita usar network_mode: host a menos que necesite ejecutar el servicio en el host.
Además, el contenedor de vídeo necesita saber el nombre del servicio/contenedor en el que se ejecuta VNC para registrar el flujo. En este ejemplo, basado en el archivo docker-compose que comparte, DISPLAY_CONTAINER_NAME=chrome debería ser en realidad DISPLAY_CONTAINER_NAME=selenium.