Skip to content

use observer

c0b edited this page Feb 18, 2019 · 10 revisions

Note: for image size and many other considerations, the wx widgets dependencies are only built into the developer friendly version: the default series like elixir:1.8 elixir:1.7 which are based on a full-featured debian based envrionment; do not expect observer to work in slim or alpine series.

examples of using observer

since erlang:19.2 images the tk libraries dependencies were added, hence running observer from the container is now possible; elixir:1.4 is based on erlang19 images and released after erlang:19.2, so it has the same ability to run any erlang / elixir tk based apps, the most prominent one is the Erlang observer

while it depends which client X window is used, the actual way of how it works might be different:

docker engine running on Linux local

mount bind the ~/.Xauthority, like docker run -it --rm -v ~/.Xauthority:/root/.Xauthority elixir

docker engine running on Linux remote, X over ssh

in many cases, if the localhost is not running Linux (like the Mac / Windows), the docker engine is running on remote Linux server (could be really remote, or in a virtual machine), need ssh with X forwarding, mount binding the ~/.Xauthority, and set proper DISPLAY, and docker run with --network=host

<local>$ ssh -XY <remote>
<remote>$ docker run -it --rm -v ~/.Xauthority:/root/.Xauthority -e DISPLAY=$DISPLAY --network host elixir
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.4.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :observer.start

observer with elixir:1.4

explanations why all these are needed:

  1. ssh -X enable X11 forwarding over ssh, run env from the X enabled remote shell you may notice the difference is it sets DISPLAY to enable X programs running on remote host, but drawing over X Server, here the X Server is usually on localhost, so usually you may see DISPLAY=localhost:11.0; the X protocol is the number 11 + base offset 6000, so sshd is listening on tcp port 6011 of 127.0.0.1; -Y is trusted X11 forwarding
  2. the -v ~/.Xauthority:/root/.Xauthority is needed to mount the Xauthority file as volume, so the X applications (the observer) can talk over the authorized X Server; the default run root in container is root, so mount it to /root/... but if you run with other uid/gid, mount into the other user's home directory can also work, but would need more complex permission granting.
  3. the -e DISPLAY=$DISPLAY is to set DISPLAY as same as on the host
  4. the --network=host is also needed here, it let the container use same network as the remote host, because otherwise docker engine will set up a veth pairs and move one into the isolated container, then it becomes unable to talk to localhost:11.0 over which sshd is listening on remote host only, X forwarding is not enabled into the further isolated container.