How to install apps with Docker on Yunohost (how I did it)

Update 14.2.2024, nearly two years later:
As you can see in the comments to my original post (see below), there are far more easier ways to install apps with Docker. First, docker compose makes installation and updating easier, and we have the Redirect and the Reverse Proxy apps!

So this how I do it in 2024:

  1. Add a new subdomain for Trilium with Let’s Encrypt cert in the Webadmin
  2. Create a folder for Trilium mkdir /home/TheNomad11/trilium
  3. add a docker compose file: sudo nano docker-compose.yml and paste something like this:
version: '3.3'
services:
    trilium:
        ports:
            - '127.0.0.1:6080:8080'
        volumes:
            - './trilium-data:/home/node/trilium-data'
        container_name: trilium
        image: 'zadam/trilium:latest'
        restart: unless-stopped

volumes:
  trilium:

Then install the Reverse Proxy app YunoHost app store | Reverse Proxy , choose the Trilium domain and then in the field Redirect destination path (unix:/file for socket) add the Trilium port, in my case 127.0.0.1:6080

That’s it, much easier!

Regarding Trilium, check these news Announcement: Trilium transitions into maintenance mode · Issue #4620 · zadam/trilium · GitHub


Original post from 2022

Hi! I am excited that I was able to install an app with Docker on Yunohost, so I’d like to share how I did it. I am no developper, so I am not sure if I did everything the right way.

I installed the newest version of Trilium Notes as this app does not seem to work well with YH, the recent updates failed: Update to version 0.52.3 by Jules-Bertholet · Pull Request #23 · YunoHost-Apps/trilium_ynh · GitHub

  1. So first I installed Docker Install Docker Engine on Debian | Docker Docs

  2. Then add a new domain for the app and the Letsencrypt certificate in the YH webadmin

  3. Install MyWebapp in the YH webadmin

  4. Run the docker command of your app.
    In my case I had to create the necessary folder first

mkdir /home/TheNomad11/trilium-data

then for Trilium

docker run -d -p 0.0.0.0:6080:8080 -v /home/TheNomad11/trilium-data:/root/trilium-data --name trilium zadam/trilium:0.53.2 && docker exec -t -i -u root trilium chown -R node:node /root/trilium-data && docker stop trilium && docker run -d -p 0.0.0.0:6080:8080 -v /home/TheNomad11/trilium-data:/home/node/trilium-data zadam/trilium:0.53.2
  1. Edit the nginx-configuration of the domain your app uses, copy and paste the nginx proxy from the app installation instruction.

In case for Trilium: Nginx proxy setup · zadam/trilium Wiki · GitHub

You just need to replace the domain and the port and don’t forget YH-specific parts of the configuration

In my case it looks like this:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}



# This part is for proxy and HTTPS configure
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name trilium.my-yunohost-domain.com;

    
    
   include /etc/nginx/conf.d/security.conf.inc;

    ssl_certificate /etc/yunohost/certs/trilium.my-yunohost-domain.com/crt.pem;
    ssl_certificate_key /etc/yunohost/certs/trilium.my-yunohost-domain.com/key.pem;
 
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://localhost:6080; #change it to your IP and port
        proxy_read_timeout 90;
        proxy_redirect http://localhost:6080 https://trilium.my-yunohost-domain.com; #change them based on your IP, port and domain
    }
}
# This part is for HTTPS forced
server {
            listen 80;
            server_name trilium.my-yunohost-domain.com; # change to your domain
            return 301 https://$server_name$request_uri;
}





server {

 
    
    

    location ^~ '/.well-known/autoconfig/mail/' {
        alias /var/www/.well-known/trilium.my-yunohost-domain.com/autoconfig/mail/;
    }

    access_by_lua_file /usr/share/ssowat/access.lua;

    include /etc/nginx/conf.d/trilium.my-yunohost-domain.com/*.conf;

    include /etc/nginx/conf.d/yunohost_sso.conf.inc;
    include /etc/nginx/conf.d/yunohost_admin.conf.inc;
    include /etc/nginx/conf.d/yunohost_api.conf.inc;

    access_log /var/log/nginx/trilium.my-yunohost-domain.com-access.log;
    error_log /var/log/nginx/trilium.my-yunohost-domain.com-error.log;
}

# vhost dedicated to XMPP http_upload
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name xmpp-upload.trilium.my-yunohost-domain.com;
    root /dev/null;

    location /upload/ {
        alias /var/xmpp-upload/trilium.my-yunohost-domain.com/upload/;
        # Pass all requests to metronome, except for GET and HEAD requests.
        limit_except GET HEAD {
          proxy_pass http://localhost:5290;
        }

        include proxy_params;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'HEAD, GET, PUT, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Authorization';
        add_header 'Access-Control-Allow-Credentials' 'true';
        client_max_body_size 105M; # Choose a value a bit higher than the max upload configured in XMPP server
    }

    include /etc/nginx/conf.d/security.conf.inc;

    ssl_certificate /etc/yunohost/certs/trilium.my-yunohost-domain.com/crt.pem;
    ssl_certificate_key /etc/yunohost/certs/trilium.my-yunohost-domain.com/key.pem;

    
    

    access_log /var/log/nginx/xmpp-upload.trilium.my-yunohost-domain.com-access.log;
    error_log /var/log/nginx/xmpp-upload.trilium.my-yunohost-domain.com-error.log;
}


  1. Restart or reload Nginx and voila, it’s done!

Does this look okay? For me at least, it works!

4 Likes

I just did a similar thing, but I used the redirect app to create an app tile in the SSO that redirects to custom ports. Works well too :slight_smile:

7 Likes

I confirm. My docker compose is running locally with ports exposed locally only and then using the redirect app to give access to my users (or the world based on the redirect option)

3 Likes

Interesting. I’m sometimes tempted to use docker on yunohost. I know it’s not the yh way to do things, but it is just so easy to run almost anything.

Why the xmpp stuff in the nginx conf? I never really understood the point of installing it by default on all yunohost installs, but I think certainly don’t get the need to have it on every domain.

2 Likes

:wave: There’s an list about app. package with a docker solution ?

Can you reformulate? Your question does not make sense. :sweat_smile:

Haha true, no sense XD .
I’m looking for apps in the catalog configured with docker, I want to setup Appflowy, but the deployment documentation uses docker.

YunoHost will not use Docker to install apps, that’s why this thread exists.

Look at the solution above of manually installing Docker and using the Redirect app in proxy mode.

1 Like
  1. Install MyWebapp in the YH webadmin

Can you explain this ? I would like to do so with an app which is not on yunohost (you installed trillium notes on ynh right ?)

it is better to use the redirect app or the reverse proxy app and enter the details there, as others explained in this thread. yes installed Trilium with docker compose.now iI know a bit more than in my first post… maybe I should edit and update it…

maybe I should edit and update it…

I would love it!

@freddewitt Done! I hope it works for you! I hope everything is correct, I am no expert.

Thanks so much ! i am begginer, i try to install this software : Studio Server - WireBear

OKay so i tried to install my app on docker.

I’ve got an error :
docker: Error response from daemon: driver failed programming external connectivity on endpoint studio-server (b94b34dff3d563bc568098b1cb8e8471c862194c17ba3a1bbb48a5cba843cb6c): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use

It’s mattermost which using postgresql. Two apps can’t use postgresql ?

Thanks

Two programs cannot listen to the same port, in this case 5432

1 Like

In your docker command you have

-p 5432:5432

You can change it so that another port is exposed, like this

-p 5433:5432

I hope it works for you!

1 Like

So the script install was :


docker run --name studio-server \
        -d \
        --restart unless-stopped \
        --network bridge \
        -e TZ=Europe/London \
        -p 5432:5432 \
        -p 50059:50059 \
        -p 8543:8543 \
        -v $PWD/hooks/:/var/studio-server/hooks/ \
        -v $PWD/database/:/var/studio-server/database/ \
        -v $PWD/backups/:/var/studio-server/backups/ \
        -v $PWD/jobs/:/etc/cron.d/ \
        allebb/studio-server:latest

I revere proxy to 5432 to my domain name and i have access de to the server configuration. But for now i can’t connect to the server with my ip or domain name. Does i have to put an domain name for each port ?

No, you reverse proxy to 8543.
Port 5432 is your database. Don*t forget to change

-p 5432:5432 \

to

-p 5433:5432 \

to avoid the port conflict you mentioned earlier

I did and it worked well (thx!)
port 50059 is for postgresql too ?

The problem now is that client doesn’t connect to the server, with the ip or the domain name.

Such things happen. There can be many reasons.
First check if the containers are running

sudo docker ps -a

and then the logs

docker logs -f containername

see here https://docs.docker.com/get-started/docker_cheatsheet.pdf