Docker Container, redirect?

Hallo

I’m new to Yunohost. It is a great peace of software.
I have installed it on a VPS and everything works proberly.

My Problem: I need a few more Applications. Which are not available as app,
for example groupoffice. I’m not able to make a app package.
For testing I installed Portainer as Container with port 9000. Serverip:9000 works great.

And now I need to make a sub.domain and forward it intern to the docker Container.
I try it with the redirect app. I have a dashboard icon. And that redirect to the portainer
Login Page. But I can’t login. The same with Ajenti I installed (no docker) when I log in
the Site freezes.
Is this a buck in the redirect app?
What are right settings in the redirect app? (I use http://127.0.0.1:port proxy invisible)
Is there a better way to make Container available as sub Domain and in the portal?
What is the right way to get a certificate for the docker applications?
(SSO is not so important)

Thanks for your help!

2 Likes

I am having this same issue right now. Did you find a solution?

Actually - it looks like the Redirect app was built just for this case!

2 Likes

Hello, I’m using YunoHost and I’m also in search of a ‘how-to-guide’ on installing additional applications using docker containers, preferably linking them to the YunoBoard-dashboard (through the Redirect-app, if I am correct?). I managed to install the Portainer-app on YunoBoard, I downloaded an application image (ex: metabase), and created a container using this downloaded image.

Now… I’m stuck :stuck_out_tongue: I have been looking around on different fora to find pointers on how to move forward, but no luck until now. Do you have a clue on how to make the app (metabase in this case) usable & integrate it in the YunoBoard dashboard? If this thread prooves succesfull at some point, we could make a short ‘DIY-HowTo’-guide for the YunoBoard-wiki maybe…

Yes, the redirect app, in proxy pass / reverse proxy mode …

Cool, thanks for your fast answer! In the meantime I stumbled upon this thread, with some more pointers on how to move forward. However, I’m not really used to work with docker and specifically redirect urls & ports, so on that part I hope the author is willing to write a short summary of steps to take… I realize the open source way of things is ‘learning by doing’, so I will also try to get up speed with the extra information provided there.

Sorry that I never really got around to writing things up! The short one that I can do right now is

  1. make a unique URL for the docker thing—maybe theres a way to do subdomains, idk, but anyhow thing.domain.com. make it have a https. so https://thing.domain.tld

  2. go to portainer. depending if you have a stack or a single container (prob the latter) go to that and click add stack or add container.

  3. fill out deets as needed. for stack, your compose file, for container your name (thing here) and image from docker hub. click publish all ports

You’ll have to look at an individual container to see what port they publish on. sometimes it’s like a random number that wont conflict with your YNH setup, but if it’s like 80 or 25 you need to change it with “port mapping” so like 9283:80

image

  1. I did a lot of tinkering of where the volume went but I don’t think any of it was needed, portainer and YNH should take care of that. volume is where on your server it goes. i cant give advice

  2. deploy container

6, go back to ynh. install the redirect app on whatever domain you set for this

  1. fill it out like this

  2. cross your fingers and hope it works. sometimes things do, sometimes they just don’t work. try googling around if not, with errors from the docker logs. sometimes env tweaking fixes it sometimes not. I don’t know enough to give advice why

2 Likes

Wonderful, thanks a lot for your writeup! And even nicer, it worked out! It feels like magic :slight_smile: And thanks to your example and deployment I kind of start to understand the role of ports (on a very brief/meta-level), they redirect towards a ‘place’ on the webserver, without the need for using url’s? Maybe this is not the place for that kind of questions, in brief: you helped me (and hopefully others) a lot, thanks!

Next step will be to understand how to configure databases (mysql, postgres, …) used by different applications, and how those interact with YunoHost. I guess that is where the ‘magic’/knowledge of contribution and verification of indexed/official YunoHost packages happens… ?

Litteraly, a port is a door where communication happens. It can be web communication (like serving a webpage, an API, etc.), email, websocket, whatever way a software communicates with other software. :slight_smile:

You can install whatever you want within Docker, YunoHost does not care very much what happens in there. We could imagine having YunoHost packages for Docker apps, as they are only a list of Bash commands, but containerization is not YunoHost’s focus.

Hence this tutorial, to understand how to serve Docker’s ports with YunoHost’s Redirect app. :wink:

You can find this information on Docker tutorials. As said above, YunoHost does not mind about what is happening within Docker. :wink: It only needs to step in whenever you want to make a port available to the outside.

1 Like

Thank you for your reply. I might have started mixing two threads, but just to note that another guideline/writeup was written by @jensensen2 over here.

These writeups helped lot to make the applications installed with Portainer + Redirect function, by:

  1. [Portainer] download of application image
  2. [Portainer] create container using image, publish exposed ports
  3. [Redirect] create a redirect to the Docker container, by redirecting to appname.myname.nohost.me:portnumber (example: huginn.myname.nohost.me:49156) by taking the first port as indicated in Portainer:

…but suddenly I now get 502 Bad Gateway NGINX errors for all of the applications and the procedure above does not work anymore. I can’t rule out the reason for that, but I assume this has to do with the ports/ip’s and the link with nginx proxy manager, as explained by @jensensen2:

Inorder to link the portainer container-apps to a new url created in YunoHost (http://appname.myname.nohost.me/), do you or somebody knows:

  • which IP/url to use to redirect to Portainer apps (http://ip_or_url/) , and where to find it?
  • which port to use to append to the IP/url (http://ip_or_url:port) ?

It could also be that the procedure described above is the correct one, and that there is another reason for the bad gateway ngix-errors, but I don’t have the expertise to rule that out… :stuck_out_tongue:

The format for ports binding is host_port:container_port, which means that on the host/yunohost side you call on the host_port, which is transferred to the container_port within the container.

Can you try a Redirect to http://127.0.0.1:host_port/ instead?

Ok I see, thanks for the explanation. I tried that, using the host_port from Portainer…

…in Redirect:

At the moment still a 502 Bad Gateway nginx error.
image

Then I tried removing the original domain huginn.myname.nohost.me (which appears to tingle with nginx-configuration)…
image

…and recreating it
image

But this still gives the bad gateway error… Mm…

As background info, from Diagnosis & cron email notifications (maybe this rules out - I don’t hope ‘add’ :p) some issues:

  • Backports: It looks like apt (the package manager) is configured to use the backports repository. Unless you really know what you are doing, we strongly discourage from installing packages from backports, because it's likely to create unstabilities or conflicts on your system
  • System resources:
    • The system has only 44 MiB (2.0%) RAM available! (out of 1.9 GiB)
    • Some processes were recently killed by the system because it ran out of memory. This is typically symptomatic of a lack of memory on the system or of a process that ate up to much memory. Summary of the processes killed: java (x2) python (x1) ruby2.5 (x1)
  • I get a daily message from root@myname.nohost.me titled Cron root@myname yunohost dyndns update >> /dev/null with Failed to resolve dyndns.yunohost.org

First you should make sure Huginn is running alright within the container itself. Refer to its documentation to do so.

Regarding the Diagnosis warnings you are getting, only the RAM one seems problematic for the matter at stake. Running multiple Docker containers, Java apps and Ruby apps on a 2GB RAM system seems a tad optimistic. :wink: And as you see, Linux has already chosen to kill some processes to save itself.

Hmm ok, I see… I might need to start reducing my footprint a little bit before continuing the experimentation journey :slight_smile: I installed NetData, and under the heading ‘Applications’ is see that sql is eating up most of the cpu/memory space. I’m primarily testing out some applications, so I’ll remove some of them…


And when running ps -o pid,user,%mem,command ax | sort -b -k3 -r (don’t remember where I found that… :)), it points also primarily at sql and secondly netdata, wikijs and etherpad.

Do you know if there is a fast trick/tool that can help in pointing out which YunoHost/Portainer-applications do use most of the RAM/memory and/or CPU (sql) ? (aligns a bit with this thread, but I didn’t find the answer to that question there. With a disclaimer: I don’t want to take advantage of asking relentlessly any question I bump into, I am already very happy with the info you gave!)

EDIT: It seems like switching the Portainer-containers off does reduce considerably memory-usage… So I might stick to official YunoHost-applications for the moment, I guess they are better integrated in the system?

It is not about better integration, it is about better fitting your server to your needs. :slight_smile: Containerization also adds overhead (CPU and memory usage) to the apps’ needs themselves. :wink:

1 Like

Ok I see, I was wondering about that as well… (not only for Docker, but also within other frameworks: conda environments, etc… if that can be compared to some extent). As I work primarily on climate change, I would also like not to create unnecessary server activity… But that’s a larger discussion with some trade-offs to make I guess :slight_smile: On that note, I like a lot the (i) content and (ii) approach of solar.lowtechmagazine.com. I guess in the server-world similar reflections/activities are ongoing, but I have still quite a learning curve to go to properly understand them :slight_smile:

1 Like