miti.sh/docs/2023-10-08-start-erlangs-dialyzer-with-gui-from-a-docker-container.md
2025-05-11 15:06:23 -07:00

52 lines
1.5 KiB
Markdown

---
title: "Start Erlang's Dialyzer With GUI From A Docker Container"
blurb: "Everything in OTP is command-line driven, so using containers during development has been without issue. But, Dialyzer, Erlang's static analysis tool, actually has a Graphical User Interface. How can we still use Dialyzer and its GUI even though Elixir is running inside a container?"
...
{
id: "start-erlangs-dialyzer-with-gui-from-a-docker-container"
}
I use Docker mostly when working on software projects and I figured out how to get Erlang's Dialyzer GUI working in a Docker container.
1. Start a container with X11 forwarding:
```
$ docker run -it --rm --net=host -e "DISPLAY" -e "NO_AT_BRIDGE=1" \
-v "$XAUTHORITY:/root/.Xauthority:rw" elixir bash
```
2. Build ["the recommended minimal PLT for Erlang/OTP"](https://www.erlang.org/doc/apps/dialyzer/dialyzer_chapter#the-persistent-lookup-table):
```
# dialyzer --build_plt --apps erts kernel stdlib mnesia
Creating PLT /root/.cache/erlang/.dialyzer_plt ...
...
done (warnings were emitted)
```
3. Start the Dialyzer GUI:
a. From the command line:
# dialyzer --gui
b. From inside an IEx session:
1. Start the Dialyzer application:
```elixir
iex(1)> Application.load(:dialyzer)
:ok
```
2. Start the Dialyzer GUI:
```elixir
iex(2)> :dialyzer.gui()
```
You should now see the Dialyzer GUI.
![dialyzer application window](/images/dialyzer.png)