Tin Hat / Run a server / Docker

Tin Hat Server with Docker

For a machine that already runs Docker: one compose file starts the same server as the image and the Linux script, set up and looked after the same way. Updates are a docker compose pull and up -d, and a version that does not start properly goes back by itself.

Docker + compose64-bit Intel/AMDOne compose file
1One filedocker-compose.yml
2docker compose up -da few minutes, mostly downloading
3Finish in your browserthe address in its log
4Invite your groupfrom the dashboard

Before you start

  • Docker Engine with the compose plugin, on Linux, on a 64-bit Intel/AMD machine: a homelab server, Portainer or CasaOS, or a NAS with a container app (Unraid, TrueNAS SCALE, Synology Container Manager; NAS systems aren't tested yet). ARM comes later. Not Docker Desktop (on Windows use Tin Hat Server for Windows, on a Mac a virtual machine), not rootless Docker, and not SELinux in enforcing mode.
  • These ports on the machine: TCP 80 and 443, TCP 7881 and UDP 7882 (or 8080 instead of 80 and 443, behind your own reverse proxy).
  • Two folders, /var/lib/tinhat (your server: accounts, messages, files, keys) and /opt/tinhat (the installed release). Back up the first one with the rest of your NAS.

Tin Hat starts its parts (chat server, database, calls, web server, the extras) as containers of their own through the Docker socket, the way the other editions do. That's why the compose file mounts the socket and the two folders at the same paths (keep them as they are). Access to the Docker socket is as good as root on the machine: Tin Hat uses it only to run and update its parts, but if that's too much trust for a machine that runs other important things, give Tin Hat a virtual machine of its own.

Start it

  1. Get the compose file into a folder of its own
    mkdir tinhat && cd tinhat
    curl -fsSLO https://github.com/TinHatLabs/TinHatServer/releases/latest/download/docker-compose.yml
  2. Start it
    docker compose up -d
  3. Read the address and the setup code in its log
    docker logs tinhat-manager

    It prints the setup page (http://<this machine>/) and an 8-digit code. Open the page on a computer or phone on the same network and follow the steps. The code again later: docker exec tinhat-manager tinhat setup-code.

Behind your own reverse proxy

If nginx, Caddy, Traefik or Nginx Proxy Manager already has ports 80 and 443 on this machine (also in a container on it), put TINHAT_BEHIND_PROXY=1 in a .env file next to the compose file before you start it. The setup page then answers on port 8080; choose My own domain → My own reverse proxy, and the last page shows the settings to paste into your proxy. Calls don't go through it: TCP 7881 and UDP 7882 come straight to the machine.

A proxy on another computer doesn't need the setting: leave it out, start as usual, and choose My own domain → My own reverse proxy at setup. (With the setting, Tin Hat checks call sign-ins through a proxy on this machine; if there's none, calls can't sign in, and docker logs tinhat-manager says so.)

Updates

docker compose pull && docker compose up -d

The new version installs itself the way it does on every Tin Hat server: a safety copy of the database and settings first, then a check that everything answers. If it doesn't start properly, it goes back to the version you had by itself, and doesn't try that version again unless you ask (TINHAT_RETRY_UPDATE=1 docker compose up -d). The dashboard says when a new version is out. To stay on one version, set TINHAT_VERSION=0.3.21 in .env. Every setting the compose file reads is described in default.env.example, next to it in each release.

What's different from the other editions

  • Home-network names (yourname.local) need the machine's own avahi: on a machine that runs avahi-daemon, uncomment the D-Bus line in the compose file. Otherwise choose Friends anywhere (a free yourname.tinhat.me) or your own domain.
  • No USB-stick backups (a container can't mount drives). Use Download a backup in the dashboard, or back up /var/lib/tinhat with your NAS's tools while the server is stopped.
  • The tinhat command lives in the container: docker exec tinhat-manager tinhat status.

Remove it

In the compose file's folder:

docker compose down
docker compose -p tinhat -f /opt/tinhat/compose.yaml --env-file /var/lib/tinhat/compose.env down

The first stops the manager, the second the parts it started. Your server's data stays in /var/lib/tinhat (delete that folder to remove it too) and the release in /opt/tinhat. The parts' images stay as well: docker images lists them.