Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount Xauthority into Docker containers (#173) #175

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions moveit2/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@ IMG_NAME=openrobotics/moveit2
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")"

# Start the container
docker run --rm -it --name $CONTAINER_NAME --network host \
-e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 $IMG_NAME
# --rm: delete container after exiting
# -it: Interactive TTY mode so you can use a shell.
# --network host: Does not isolate Docker container from host's network interfaces.
# Allows all traffic to pass through as if it originated from the host.
# In our case, useful for DDS traffic for ROS.
# -e DISPLAY: Pass the X11 display through to the container.
# -e TERM: Pass the kind of terminal being used through to the container.
# -e QT_X11_NO_MITSHM=1: Disables shared memory extension for Qt/X11, which does not work consistently inside a process namespace like a container.
# -v "$XAUTHORITY:/.Xauthority": the $XAUTHORITY environment variable on the host contains the path to a file that grants access to X11.
# We mount the path defined in that environment variable into the container at /.Xauthority.
# -e XAUTHORITY=/.Xauthority: We set $XAUTHORITY *inside* the container to the place we just mounted the Xauthority (/.Xauthority)
docker run --rm -it --name $CONTAINER_NAME \
--network host \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
-v "$XAUTHORITY:/.Xauthority" \
-e XAUTHORITY=/.Xauthority \
$IMG_NAME
21 changes: 19 additions & 2 deletions nav2_demo/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@ IMG_NAME=osrf/space_nav2_demo
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")"

# Start the container
docker run --rm -it --name $CONTAINER_NAME --network host \
-e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 $IMG_NAME
# --rm: delete container after exiting
# -it: Interactive TTY mode so you can use a shell.
# --network host: Does not isolate Docker container from host's network interfaces.
# Allows all traffic to pass through as if it originated from the host.
# In our case, useful for DDS traffic for ROS.
# -e DISPLAY: Pass the X11 display through to the container.
# -e TERM: Pass the kind of terminal being used through to the container.
# -e QT_X11_NO_MITSHM=1: Disables shared memory extension for Qt/X11, which does not work consistently inside a process namespace like a container.
# -v "$XAUTHORITY:/.Xauthority": the $XAUTHORITY environment variable on the host contains the path to a file that grants access to X11.
# We mount the path defined in that environment variable into the container at /.Xauthority.
# -e XAUTHORITY=/.Xauthority: We set $XAUTHORITY *inside* the container to the place we just mounted the Xauthority (/.Xauthority)
docker run --rm -it --name $CONTAINER_NAME \
--network host \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
-v "$XAUTHORITY:/.Xauthority" \
-e XAUTHORITY=/.Xauthority \
$IMG_NAME
21 changes: 19 additions & 2 deletions navigation2/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,22 @@ IMG_NAME=osrf/space_nav2
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")"

# Start the container
docker run --rm -it --name $CONTAINER_NAME --network host \
-e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 $IMG_NAME
# --rm: delete container after exiting
# -it: Interactive TTY mode so you can use a shell.
# --network host: Does not isolate Docker container from host's network interfaces.
# Allows all traffic to pass through as if it originated from the host.
# In our case, useful for DDS traffic for ROS.
# -e DISPLAY: Pass the X11 display through to the container.
# -e TERM: Pass the kind of terminal being used through to the container.
# -e QT_X11_NO_MITSHM=1: Disables shared memory extension for Qt/X11, which does not work consistently inside a process namespace like a container.
# -v "$XAUTHORITY:/.Xauthority": the $XAUTHORITY environment variable on the host contains the path to a file that grants access to X11.
# We mount the path defined in that environment variable into the container at /.Xauthority.
# -e XAUTHORITY=/.Xauthority: We set $XAUTHORITY *inside* the container to the place we just mounted the Xauthority (/.Xauthority)
docker run --rm -it --name $CONTAINER_NAME \
--network host \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
-v "$XAUTHORITY:/.Xauthority" \
-e XAUTHORITY=/.Xauthority \
$IMG_NAME
21 changes: 19 additions & 2 deletions space_robots/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@ IMG_NAME=openrobotics/space_robots_demo
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")"

# Start the container
docker run --rm -it --name $CONTAINER_NAME --network host \
-e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 $IMG_NAME
# --rm: delete container after exiting
# -it: Interactive TTY mode so you can use a shell.
# --network host: Does not isolate Docker container from host's network interfaces.
# Allows all traffic to pass through as if it originated from the host.
# In our case, useful for DDS traffic for ROS.
# -e DISPLAY: Pass the X11 display through to the container.
# -e TERM: Pass the kind of terminal being used through to the container.
# -e QT_X11_NO_MITSHM=1: Disables shared memory extension for Qt/X11, which does not work consistently inside a process namespace like a container.
# -v "$XAUTHORITY:/.Xauthority": the $XAUTHORITY environment variable on the host contains the path to a file that grants access to X11.
# We mount the path defined in that environment variable into the container at /.Xauthority.
# -e XAUTHORITY=/.Xauthority: We set $XAUTHORITY *inside* the container to the place we just mounted the Xauthority (/.Xauthority)
docker run --rm -it --name $CONTAINER_NAME \
--network host \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
-v "$XAUTHORITY:/.Xauthority" \
-e XAUTHORITY=/.Xauthority \
$IMG_NAME
Loading