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

Would it be possible to use this on macOS using xQuartz? #8

Open
lubaroli opened this issue Mar 26, 2020 · 4 comments
Open

Would it be possible to use this on macOS using xQuartz? #8

lubaroli opened this issue Mar 26, 2020 · 4 comments

Comments

@lubaroli
Copy link

I've installed xQuartz and tried running this docker-box, but I get an error I can quite figure out how to handle.

When installing:
~/> ./init-ros-box.sh melodic ~/ROS
Prepare the target environment...
Build the docker image... (This can take some time)
sha256:xxx
create a new container from this image...
xauth: (argv):1: unable to read any entries from file "(stdin)"
ca40c0b23e3b1c645a24c665c2e8f72cc4582ef911422ac9a35bd607b81dae1b

Then, when running:
~/> ./go.sh
Starting previously stopped container...
Error response from daemon: error gathering device information while adding custom device "/dev/dri/card0": no such file or directory
Error: failed to start containers: ca40c0b23e3b
Error response from daemon: Container ca40c0b23e3b1c645a24c665c2e8f72cc4582ef911422ac9a35bd607b81dae1b is not running

Anyone knows how to get this up and running?

Thanks

@rmaronson
Copy link

I also ran into this issue. Here's my workaround:

  1. Edit the files as such

In init_ros_box.sh:

remove the line
--device=/dev/dri/card0:/dev/dri/card0

remap the display to run over tcp by replacing the DISPLAY spec on docker create with
-e DISPLAY=host.docker.internal:0 \

In go.sh:

At the beginning somewhere (I have it right after the container_id=... line add

# Run socat workaround for X11 connection
if [ -e "$script_dir/socat.pid" ]; then
    socat_pid=$(cat "$script_dir/socat.pid")
else
    socat_pid=""
fi

if [ -z "$socat_pid" ] || ! ps "$socat_pid" >/dev/null; then
    socat TCP-LISTEN:6000,range=127.0.0.1/32,fork UNIX-CONNECT:/tmp/.X11-unix/X0 &
    echo "$!" >"$script_dir/socat.pid"
    echo "Started socat on pid $!"
fi
  1. Install socat (e.g. brew install socat)

The main issue is that docker for mac doesn't allow shared unix sockets between host and containers. The workaround is to use socat to expose a local port for XQuartz to run on. (In theory, it should be possible to have XQuartz open a tcp port itself, but I couldn't figure out how.)

Note that X running over TCP is generally not safe; the range=127.0.0.1/32 line in the socat command limits it to localhost connections which should help.

If there is interest, I can try to make a PR. I don't really understand how the xauth stuff works, so I'm not sure how this setup would interact with it, which is my hesitance for now.

@lubaroli
Copy link
Author

lubaroli commented Oct 8, 2020

@rmaronson, using your workaround I managed to install and run the docker image (I've used ROS Noetic on Ubuntu), however whenever I try to run Gazebo or RViz I still get error messages.

Running Gazebo:

2020/10/08 16:19:25 socat[43615] E connect(5, LEN=19 AF=1 "/tmp/.X11-unix/X0", 19): No such file or directory
2020/10/08 16:19:25 socat[43616] E connect(5, LEN=19 AF=1 "/tmp/.X11-unix/X0", 19): No such file or directory
2020/10/08 16:19:25 socat[43617] E connect(5, LEN=19 AF=1 "/tmp/.X11-unix/X0", 19): No such file or directory

Running RViz:

2020/10/08 16:22:41 socat[43707] E connect(5, LEN=19 AF=1 "/tmp/.X11-unix/X0", 19): No such file or directory
qt.qpa.xcb: could not connect to display host.docker.internal:0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted

I can see socat has a process running using ps -a:

44105 ttys002    0:00.01 socat TCP-LISTEN:6000,range=127.0.0.1/32,fork UNIX-CONNECT:/tmp/.X11-unix/X0

Any ideas what is going on?

@rmaronson
Copy link

I'm not sure what you're running into. I should say: I ended up giving up on x-forwarding, since I had an issue getting graphical acceleration/glx working over that socket. I'm now using this package + noVNC and combining the docker images together. Unfortunately I can't track down exactly which noVNC image I worked from (might be https://hub.docker.com/r/babim/ubuntu-novnc), but it looks like there are several available.

@lubaroli
Copy link
Author

lubaroli commented Oct 8, 2020

Thanks @rmaronson, I've managed to start the ros-box container by simplifying the build instructions removing the xauth hooks and following the procedure on this post.

However, I fell under the same rabbit hole and now have an error running 3D accelerated graphics (gazebo/rviz)... Something about libGL error and swrast driver: https://stackoverflow.com/questions/44166269/libgl-error-failed-to-load-driver-swrast-in-docker-container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants