Can't user :observer.start inside container

I run phoenix server into container at Mac, I run the container as:

docker run -p 4011:4011 -p 4033:4033 -v ~/.Xauthority:/root/.Xauthority -v /Users/samir/Documents/projects/elixir:/usr/src -e DISPLAY=$DISPLAY --network host -it elixir:1.5.2 bash

then, when I start phoenix as:

iex -S mix phx.server

I got error when try to run :observer.start:

iex(1)> :observer.start
13:50:45: Error: Unable to initialize GTK+, is DISPLAY set properly?
{:error,
{{:einval, ‘Could not initiate graphics’},
[{:wxe_server, :start, 1, [file: ‘wxe_server.erl’, line: 65]},
{:wx, :new, 1, [file: ‘wx.erl’, line: 115]},
{:observer_wx, :init, 1, [file: ‘observer_wx.erl’, line: 98]},
{:wx_object, :init_it, 6, [file: ‘wx_object.erl’, line: 372]},
{:proc_lib, :init_p_do_apply, 3, [file: ‘proc_lib.erl’, line: 247]}]}}

inside container:

$ echo $DISPLAY
/private/tmp/com.apple.launchd.xdi35OUtZR/org.macosforge.xquartz:0

Any idea?

What is it that you are trying to do? It is possible to connect to a remotely running Elixir or Erlang shell (or also one inside a container) from a local shell, and run :observer there, connecting the local graphical interface with the remote data. Maybe that is a possibility?

Another thing you might be able to do is to install a fake graphics driver in the container. But in that case, you cannot actually see observer yourself.

1 Like

I am trying to run observer inside a container that is running locally on my Mac, that’s what I am trying to achieve without success…

I having issues that prevents phoenix to start into my Mac (without container), that’s why I used container.

I struggled with this also, and got the observer and other gui apps running. This is my solution: https://github.com/StefanHoutzager/elixir-dev-anywhere-docker

2 Likes