tribler icon indicating copy to clipboard operation
tribler copied to clipboard

Run tribler in docker as a web application with a gui

Open dmuiX opened this issue 2 years ago • 8 comments

Dear devs,

Nice application so far. Would be so nice if you could run this application as a web service in docker with a web gui. I want to use it on my home server. And with a web application I could use it from every device I have and let the downloads run over night. Way easier than running it locally on my notebook.

Thanks and kind regards

Daniel

dmuiX avatar Feb 04 '22 22:02 dmuiX

Okay looks like somebody has already written this enhancement in another issue. Might be good to make the suggestions there more invisible so new users like me find it when lookin on Google for tribler docker.

dmuiX avatar Feb 04 '22 22:02 dmuiX

Maybe you meant visible?

kotenok2000 avatar Feb 09 '22 15:02 kotenok2000

Yeah visible of Course :D

dmuiX avatar Feb 09 '22 17:02 dmuiX

Thank you for your suggestion!

devos50 avatar Feb 13 '22 12:02 devos50

After some fiddling I've got this working in a rudimentary fashion.

I've had to make some tweaks to the Dockerfile to get the Qt version to work, then I created another Dockerfile, which is basically a Xvfb / X11Vnc wrapper around the first image, which has all the correct librararies installed.

When I finally had it working, it turned out that api_port was not an int but a string, so not being a python guy myself, I just hacked this away:

diff --git a/src/tribler/gui/tribler_window.py b/src/tribler/gui/tribler_window.py
index 0e6b84730..3c53e1c49 100644
--- a/src/tribler/gui/tribler_window.py
+++ b/src/tribler/gui/tribler_window.py
@@ -177,6 +177,7 @@ class TriblerWindow(QMainWindow):
         api_port = api_port or default_network_utils.get_first_free_port(
             start=int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT))
         )
+        api_port = int(api_port)
         if not default_network_utils.is_port_free(api_port):
             raise RuntimeError(
                 "Tribler configuration conflicts with the current OS state: "

Then you need a simple start script which fires up xvfb / fluxbox / x11vnc / tribler (in said order) - never mind the sleeps

# Do not use 32bpp
export DISPLAYSIZE="1280x900x24"

# login with this password
export VNCPASSWORD="tribler"

export DISPLAY=:1

/usr/bin/Xvfb $DISPLAY -screen 0 "$DISPLAYSIZE" &

/usr/bin/fluxbox >/dev/null &

sleep 5
x11vnc -display $DISPLAY -bg -forever -usepw -passwd "$VNCPASSWORD" -shared -forever &

sleep 5
/tribler/src/tribler.sh

After the container has been started (mind you, this image is only local)

docker run --rm -d \
  -v $(pwd)/settings:/home/user/.Tribler \
  -v $(pwd)/download:/home/user/Downloads \
  -p 5900:5900 mivale/tribler-vnc:latest

you've got a gui version of tribler accessible via vnc running on any linux machine.

Caveat: the resulting docker image is 2.79GB and I have NOT tried downloading anything with it (it's currently not running in host mode, don't know if that's a must)

image

Notice the macos vncviewer artifacts 🤣

Let me know if anyone has interest in this and wether or not to create a pull request. You could build everything in a single container using a git clone off main (with the single int() tweak, that is).

It would be nice if someone else also were to test this 😬

Perhaps it would be better to just create a repo which does all the heavy work and leaves Tribler alone 😝

mivale avatar Nov 27 '22 22:11 mivale

Just curious, can we separate frontend from backend? For example, run a backend inside a server container, and run a GUI frontend through a client container?

allenyllee avatar Nov 28 '22 06:11 allenyllee

Glad you asked that, because that was my first thought as well, and also my first try.

Technically it must be possible but when I tried to make the gui talk to another backend on a different container by claiming the api port and forwarding it, the gui (at least on mac) spawned its own api on the next port and started talking to that one.

A setting with a backend url would make this possible. I have a feeling the api/gui combo are hardwired together.

mivale avatar Nov 28 '22 06:11 mivale

Is there any update how to run tribler on docker

febriansasi avatar Mar 24 '24 15:03 febriansasi