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

Commit 83342fd

Browse files
committed
Fix: X11 in the container.
1 parent 9f80940 commit 83342fd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docker/docker_tools.py

Lines changed: 7 additions & 6 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()
@@ -711,7 +713,7 @@ def _build_phase_1(
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.
@@ -862,12 +864,11 @@ def _build_phase_2_core(
862864
# Misc setup
863865
# ^^^^^^^^^^
864866
if build_config.is_dev():
865-
# Start up everything needed for vnc access. Handle the case of no ``DISPLAY`` available or empty.
866-
x_display = env.DISPLAY or ":0"
867+
# 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.
867868
xqt(
868869
# 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.``
869-
f"rm -f /tmp/.X{x_display.split(':', 1)[1]}-lock",
870-
f"Xvfb {x_display} &",
870+
f"rm -f /tmp/.X{env.DISPLAY.split(':', 1)[1]}-lock",
871+
"Xvfb &",
871872
# Wait a bit for Xvfb to start up before running the following X applications.
872873
"sleep 1",
873874
"x11vnc -forever &",

0 commit comments

Comments
 (0)