Skip to content

Instantly share code, notes, and snippets.

@naoki-mizuno
Created October 2, 2018 23:10
Show Gist options
  • Save naoki-mizuno/f9325cd219ec2dcb65bb6111dd78bcfd to your computer and use it in GitHub Desktop.
Save naoki-mizuno/f9325cd219ec2dcb65bb6111dd78bcfd to your computer and use it in GitHub Desktop.
#!/bin/bash
XAUTH=/tmp/.docker.xauth
if [ ! -f $XAUTH ]; then
xauth_list=$( xauth nlist :0 | sed -e 's/^..../ffff/' )
if [ ! -z "$xauth_list" ]; then
echo $xauth_list | xauth -f $XAUTH nmerge -
else
touch $XAUTH
fi
chmod a+r $XAUTH
fi
# https://qiita.com/tnarihi/items/275c009e9dec1306893f
docker run -it --rm \
--user="$( id -u ):$( id -g )" \
$( for i in $( id -G ); do echo -n " --group-add $i"; done ) \
--env="DISPLAY=$DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--env="XAUTHORITY=$XAUTH" \
--workdir="/home/$USER" \
--volume="/home/$USER:/home/$USER" \
--volume="/etc/group:/etc/group:ro" \
--volume="/etc/passwd:/etc/passwd:ro" \
--volume="/etc/shadow:/etc/shadow:ro" \
--volume="$XAUTH:$XAUTH" \
--volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--runtime=nvidia \
cartographer-ros:dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment