2

I have a project written in Golang using the Fyne framework. I am aware of the issues that are related to X11 when trying to Dockerize these type of applications. Here is my Dockerfile:

FROM golang:1.20

WORKDIR /app

COPY . .

RUN go mod download
RUN apt-get update && apt-get install -y libgl1-mesa-dev xorg-dev x11-apps dbus-x11 xvfb make
RUN make

# my Golang app takes in a single command line argument hence the ENTRYPOINT.
# specifically, the command line argument is an address the application will use.
ENTRYPOINT ["./cmd/server/server"]

Here is how I am running it: docker run -e DISPLAY=$DISPLAY -p 8080:3000 --net=host red "localhost:3000"

However, this seems to cause the error:

PlatformError: X11: Failed to open display :0
panic: NotInitialized: The GLFW library is not initialized

I am also aware of the available fyne-cross project. I attempted to use that and ran into more problems as well. I would like to try Dockerize this project myself however.

I've tried doing xhost + local:docker (I know, not secure) however the same error pops up. I have also tried: docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix red "localhost:3000" I've also tried with and without the --net=host. I saw this solution in another post but it didn't seem to do anything. For context, I am on Ubuntu.

zayaanra
  • 50
  • 5
  • This sounds not unlike [Can you run GUI applications in a Linux Docker container?](https://stackoverflow.com/questions/16296753/can-you-run-gui-applications-in-a-linux-docker-container); have you run through its various answers? You do not need `--net=host`, but you do need to bind-mount the X socket and also the `.Xauthority` file. You also need to not be running Docker Desktop. (Just running `./cmd/server/server` without Docker is probably vastly easier.) – David Maze Aug 07 '23 at 00:40
  • Yes, I can run `./cmd/server/server` locally just fine. I need my application to be accessible across different platforms, hence Docker. I did try the solutions in that post, but the same error pops up. – zayaanra Aug 07 '23 at 02:14
  • The X Window System setup is fairly specific to Linux hosts; it's very unusual to have an X server at all on a MacOS or Windows system. – David Maze Aug 07 '23 at 10:04

1 Answers1

1

To my knowledge X11 forwarding does not expose the OpenGL driver necessary to run a Fyne application. This is similar to the open issue that a Fyne app cannot be launched from headless Linux.

andy.xyz
  • 2,567
  • 1
  • 13
  • 18