InfinityDevil

Tailscale Docker Compose How-To

"Tailscale Machines List"

These instructions should help you run tailscale in a docker container using a docker-compose.yml file. They're a bit rough, but will hopefully get you where you need to go.

You must generate an auth key when signed into the Tailscale admin console: Log in, Settings, keys (under Personal Settings), create a key setting it to Reusable. This key will expire in 90 days by default. Copy this key value for pasting into the configuration file later. The key value starts with "tskey-auth".

Create a subfolder "state" under the folder to contain the docker-compose.yml file.

Each time the container runs, it will generate a new machine name with a number suffix, e.g. "machinename-1", with the old one still present.
Delete the old one using the 3-dots menu. Edit the current one using the 3-dots menu, select the Routes option, check the box for Use as an Exit Node.

To connect to this node: When signed into Tailscale app, use the 3-dots item on the menu and pick the exit node.

The docker-compose.yml file is:

version: '3.3'
services:
    tailscale:
        container_name: tailscaled
        volumes:
            - '/var/lib:/var/lib'
            - '/dev/net/tun:/dev/net/tun'
        network_mode: host
        restart: unless-stopped
        environment:
            - TS_AUTHKEY=key-mat-is-redacted
            - TS_EXTRA_ARGS=--advertise-exit-node
            - TS_ROUTES=192.168.1.0/24
            - TS_HOSTNAME=call-this-something
            - TS_STATE_DIR=./state/
        image: tailscale/tailscale

Change the TS_AUTHKEY to the actual key material. Change the TS_ROUTES value to your desired subnet. Change TS_HOSTNAME to what you want to call it.

Sources: