Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 868ff74

Browse files
authored
Merge pull request #1967 from bjones1/docker-x11
Fix: X11 in the container.
2 parents 479ff65 + 80910db commit 868ff74

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

docker/docker_tools.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ def _build_phase_0(
511511
# Set the base dedent; this defines column 0. The following section of the file should be indented by 2 tabs.
512512
# Set up for VNC.
513513
environment:
514-
DISPLAY: ${DISPLAY}
514+
# I don't know how to correctly forward X11 traffic (see notes on VNC), so ignore the X11 ``DISPLAY`` outside the container.
515+
DISPLAY: ":0"
515516
ports:
516517
# For VNC.
517518
- "5900:5900"
@@ -528,6 +529,7 @@ def _build_phase_0(
528529
- ../BookServer/:/srv/BookServer
529530
# To make Chrome happy.
530531
- /dev/shm:/dev/shm
532+
- /run/dbus/system_bus_socket:/run/dbus/system_bus_socket
531533
"""
532534
)
533535
if build_config.is_dev()
@@ -705,13 +707,13 @@ def _build_phase_1(
705707
# Tests use `html5validator <https://github.com/svenkreiss/html5validator>`_, which requires the JDK.
706708
f"{apt_install} openjdk-11-jre-headless git xvfb x11-utils {browser} lsof emacs-nox",
707709
# Install Chromedriver. Based on https://tecadmin.net/setup-selenium-with-chromedriver-on-debian/.
708-
"wget --no-verbose https://chromedriver.storage.googleapis.com/96.0.4664.18/chromedriver_linux64.zip",
710+
"wget --no-verbose https://chromedriver.storage.googleapis.com/103.0.5060.53/chromedriver_linux64.zip",
709711
"unzip chromedriver_linux64.zip",
710712
"rm chromedriver_linux64.zip",
711713
"mv chromedriver /usr/bin/chromedriver",
712714
"chown root:root /usr/bin/chromedriver",
713715
"chmod +x /usr/bin/chromedriver",
714-
# Provide VNC access. TODO: just pass the correct DISPLAY value and ports and use X11 locally, but how? Notes on my failures:
716+
# Provide VNC access. TODO: just pass the correct DISPLAY value and ports and use X11 locally, but how? Here's the `best info <http://wiki.ros.org/docker/Tutorials/GUI>`_ I've found. Notes on my failures:
715717
#
716718
# - Including ``network_mode: host`` in `../docker-compose.yml` works. However, this breaks everything else (port mapping, links, etc.). It suggests that the correct networking setup would make this work.
717719
# - Passing ``volume: - /tmp/.X11-unix:/tmp/.X11-unix`` has no effect (on a Ubuntu 20.03.4 LTS host). Per the previous point, it seems that X11 is using TCP as its transport.
@@ -870,12 +872,11 @@ def _build_phase_2_core(
870872
# Misc setup
871873
# ^^^^^^^^^^
872874
if build_config.is_dev():
873-
# Start up everything needed for vnc access. Handle the case of no ``DISPLAY`` available or empty.
874-
x_display = env.DISPLAY or ":0"
875+
# Since I don't know how to forard the X11 ``$DISPLAY`` correctly (see notes on VNC access), run a virtual frame buffer in the container and provide access via VNC. TODO: only do this if the provided ``$DISPLAY`` is not set.
875876
xqt(
876877
# Sometimes, previous runs leave this file behind, which causes Xvfb to output ``Fatal server error: Server is already active for display 0. If this server is no longer running, remove /tmp/.X0-lock and start again.``
877-
f"rm -f /tmp/.X{x_display.split(':', 1)[1]}-lock",
878-
f"Xvfb {x_display} &",
878+
f"rm -f /tmp/.X{env.DISPLAY.split(':', 1)[1]}-lock",
879+
"Xvfb &",
879880
# Wait a bit for Xvfb to start up before running the following X applications.
880881
"sleep 1",
881882
"x11vnc -forever &",

0 commit comments

Comments
 (0)