<!-- Generated from docs/*.md. Do not edit directly. -->

# DockTail Documentation

DockTail exposes Docker containers as Tailscale Services using label-based configuration. It watches Docker events, reads `docktail.*` labels, and advertises matching containers through the local Tailscale daemon.

## Why DockTail?

DockTail uses native Tailscale Services, not per-container Tailscale devices.

<div class="comparison-table-wrap">
  <table class="comparison-table">
    <colgroup>
      <col>
      <col>
      <col>
      <col>
      <col>
      <col>
    </colgroup>
    <thead>
      <tr>
        <th scope="col" aria-label="Feature"></th>
        <th scope="col">DockTail</th>
        <th scope="col">TSDProxy</th>
        <th scope="col">ScaleTail</th>
        <th scope="col">tsbridge</th>
        <th scope="col">Plain Services</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">Native Tailscale Services</th>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
      </tr>
      <tr>
        <th scope="row">Configured via Docker labels</th>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
      </tr>
      <tr>
        <th scope="row">
          Apps do not consume separate Tailscale device slots
          <span class="info-tip" tabindex="0" aria-label="DockTail advertises apps as services from one tagged host instead of creating a separate Tailscale device identity per app. Exact plan limits depend on Tailscale.">i<span role="tooltip">DockTail advertises apps as services from one tagged host instead of creating a separate Tailscale device identity per app. Exact plan limits depend on Tailscale.</span></span>
        </th>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
      </tr>
      <tr>
        <th scope="row">No app port publishing</th>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="Depends on proxy or network setup"><span class="status-mark">⚠️</span><span class="info-tip" tabindex="0" aria-label="Depends on proxy and Docker network setup.">i<span role="tooltip">Depends on proxy and Docker network setup.</span></span></td>
        <td aria-label="Depends on sidecar setup"><span class="status-mark">⚠️</span><span class="info-tip" tabindex="0" aria-label="Depends on the sidecar template and app network setup.">i<span role="tooltip">Depends on the sidecar template and app network setup.</span></span></td>
        <td aria-label="Depends on proxy or network setup"><span class="status-mark">⚠️</span><span class="info-tip" tabindex="0" aria-label="Depends on proxy and Docker network setup.">i<span role="tooltip">Depends on proxy and Docker network setup.</span></span></td>
        <td aria-label="Manual backend setup required"><span class="status-mark">⚠️</span><span class="info-tip" tabindex="0" aria-label="You configure how the service host reaches the backend yourself.">i<span role="tooltip">You configure how the service host reaches the backend yourself.</span></span></td>
      </tr>
      <tr>
        <th scope="row">Automatic Docker reconciliation</th>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
      </tr>
      <tr>
        <th scope="row">Low manual setup after install</th>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="Template setup per app"><span class="status-mark">⚠️</span><span class="info-tip" tabindex="0" aria-label="ScaleTail is template-based, so each app usually starts from its own Compose recipe.">i<span role="tooltip">ScaleTail is template-based, so each app usually starts from its own Compose recipe.</span></span></td>
        <td aria-label="Yes"><span class="status-mark">✅</span></td>
        <td aria-label="No"><span class="status-mark">❌</span></td>
      </tr>
    </tbody>
  </table>
</div>

## What DockTail Does

- Discovers labeled Docker containers automatically.
- Proxies directly to container IPs by default, so app containers do not need published Docker ports.
- Advertises HTTP, HTTPS, TCP, and TLS-terminated TCP services through Tailscale.
- Supports Tailscale HTTPS with automatic certificates.
- Supports Tailscale Funnel for public internet access.
- Supports multiple Tailscale services from one container.
- Reconciles state when containers restart and container IPs change.
- Runs as a stateless Docker container.
- Optionally reports to [DockTail Cloud](https://docktail.org/docs/cloud/), a paid hosted service, for multi-host monitoring and alerting. Opt-in via one environment variable; inert when unset.

## Recommended Reading Order

1. Start with [Quick Start](https://docktail.org/docs/quick-start/) for a minimal Compose setup.
2. Read [Installation](https://docktail.org/docs/installation/) for host Tailscale and sidecar options, [Platform Guides](https://docktail.org/docs/platforms/) for Podman, NAS systems, macOS, Windows, Swarm and Kubernetes, and [Hardening](https://docktail.org/docs/security/) to narrow what DockTail can reach.
3. Configure Tailscale permissions in [Tailscale Admin Setup](https://docktail.org/docs/tailscale-admin/).
4. Use [Labels](https://docktail.org/docs/labels/) and [Examples](https://docktail.org/docs/examples/) when exposing real services.
5. See [DockTail Cloud](https://docktail.org/docs/cloud/) if you want monitoring and alerting across your hosts.
6. Check [Reference](https://docktail.org/docs/reference/) for all labels, environment variables, protocols, and behavior notes, and [How It Works](https://docktail.org/docs/how-it-works/) for the reconciliation loop.
7. Follow a [how-to guide](https://docktail.org/docs/guides/) for a complete setup of a specific app, such as Jellyfin or Home Assistant, or for moving over from TSDProxy.


## Quick Start

### Before you start

- [ ] The Docker host is on your tailnet and tagged `tag:server` (`sudo tailscale up --advertise-tags=tag:server --reset`). On macOS, Windows and many NAS devices, use the [Tailscale sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) instead.
- [ ] Your tailnet policy lists `tag:server` and `tag:container` (the default service tag) in `tagOwners`, and `autoApprovers.services` lets `tag:server` advertise `tag:container` services. See [ACL Configuration](https://docktail.org/docs/tailscale-admin/#acl-configuration).
- [ ] Recommended: a Tailscale OAuth client for `tag:server` with **Services: Write** and **Devices Core: Write** (plus **Keys Auth Keys: Write** for the sidecar). No broader scope, such as `all`, is needed. Without credentials, you create each service in the admin console yourself. See [OAuth Credentials](https://docktail.org/docs/tailscale-admin/#oauth-credentials).

<details>
<summary>Policy snippet (tagOwners + autoApprovers)</summary>

```json
{
  "tagOwners": {
    "tag:server": ["autogroup:admin"],
    "tag:container": ["tag:server"]
  },
  "autoApprovers": {
    "services": {
      "tag:container": ["tag:server"]
    }
  }
}
```

</details>

### Run it

Then add DockTail to your Docker Compose file alongside the service you want to expose:

```yaml
services:
  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/run/tailscale:/var/run/tailscale
    environment:
      # Optional but recommended. Enables automatic service creation.
      - TAILSCALE_OAUTH_CLIENT_ID=${TAILSCALE_OAUTH_CLIENT_ID}
      - TAILSCALE_OAUTH_CLIENT_SECRET=${TAILSCALE_OAUTH_CLIENT_SECRET}

  myapp:
    image: nginx:latest
    # No ports needed. DockTail proxies directly to the container IP.
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=myapp"
      - "docktail.service.port=80"
```

Start the stack:

```bash
docker compose up -d
```

Then open the service from your tailnet:

```bash
curl http://myapp.your-tailnet.ts.net
```

The first time a service is advertised, it may need approval in the Tailscale Admin Console's Services tab; see [Approve Services](https://docktail.org/docs/tailscale-admin/#approve-services). If it does not show up, `docker compose logs docktail` names the cause, and [Installation](https://docktail.org/docs/installation/#installation) and [Tailscale Admin Setup](https://docktail.org/docs/tailscale-admin/#tailscale-admin-setup) cover each step in detail. On macOS and Windows the host's Tailscale daemon cannot be shared with containers, so use the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) setup instead. Rootless Docker on Linux needs an extra operator step; see [Rootless Docker](https://docktail.org/docs/installation/#rootless-docker). For Podman, Synology, Unraid, TrueNAS, Swarm and Kubernetes, see the [Platform Guides](https://docktail.org/docs/platforms/#platform-guides).


## Installation

DockTail needs access to the Docker socket and a Tailscale socket. Use the host setup when Tailscale already runs on a Linux Docker host. Use the sidecar setup when the host should not install Tailscale directly, or when the host's Tailscale daemon cannot be shared with containers (macOS and Windows). [Platform Guides](https://docktail.org/docs/platforms/#platform-guides) covers Podman, NAS systems, Swarm and Kubernetes, and [Hardening](https://docktail.org/docs/security/#hardening) narrows what DockTail can reach.

### Tailscale On Host

Use this setup when Tailscale is already installed on a Linux Docker host:

```yaml
services:
  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/run/tailscale:/var/run/tailscale
    environment:
      - TAILSCALE_OAUTH_CLIENT_ID=${TAILSCALE_OAUTH_CLIENT_ID}
      - TAILSCALE_OAUTH_CLIENT_SECRET=${TAILSCALE_OAUTH_CLIENT_SECRET}
```

Mount `/var/run/tailscale` as a directory rather than mounting the socket file directly. When `tailscaled` restarts, it recreates the socket with a new inode; a directory mount stays in sync.

The host setup only works on Linux. On macOS and Windows the Tailscale app does not expose a Unix socket at `/var/run/tailscale` (the local API is served over a localhost TCP port instead), and Docker Desktop runs containers in a virtual machine that cannot mount host Unix sockets anyway. If DockTail logs `dial unix /var/run/tailscale/tailscaled.sock: connect: no such file or directory`, switch to the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) setup below.

The host machine must advertise a tag that matches your ACL auto-approvers:

```bash
sudo tailscale up --advertise-tags=tag:server --reset
```

The `--reset` flag briefly drops the Tailscale connection. If you are connected through SSH over Tailscale, your session may be interrupted until Tailscale reconnects.

### Rootless Docker

When Docker runs rootless, the DockTail container is your user, not root. Host `tailscaled` then rejects serve-config writes unless that user is the Tailscale operator:

```bash
sudo tailscale set --operator=$USER
```

`tailscale set --operator` does not drop the connection. The node still needs the ACL tag from the host setup above. If it is not tagged yet:

```bash
sudo tailscale up --advertise-tags=tag:server --operator=$USER --reset
```

`--operator` lets that Unix user manage `tailscaled` (serve, Funnel, `up`/`down`). That is required for the host setup with rootless Docker. If you do not want to grant the Docker user that access, use the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) instead.

Rootless Docker also changes two paths:

**Docker socket.** Mount the user socket, not `/var/run/docker.sock`. Replace `1000` with your UID (`id -u`):

```yaml
volumes:
  - /run/user/1000/docker.sock:/var/run/docker.sock:ro
  - /var/run/tailscale:/var/run/tailscale
```

**Container reachability.** Default direct mode tells host `tailscaled` to connect to the container IP. Those IPs are often unreachable from the host in rootless Docker. If the service advertises but does not connect:

- Set `docktail.service.direct=false` and publish the container port, so Tailscale proxies to `127.0.0.1:<host-port>`.
- Or use the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) on the same Docker network as the app. Prefer that over `network_mode: host` on rootless Docker.

### Tailscale Sidecar

Use this setup when the host does not run Tailscale directly. It is the required setup on macOS and Windows (Docker Desktop, OrbStack, Colima) and on many NAS devices, because `tailscaled` runs inside the Docker environment and shares its socket with DockTail through a named volume instead of a host mount:

```yaml
services:
  tailscale:
    image: tailscale/tailscale:latest
    hostname: docktail-host
    environment:
      - TS_AUTHKEY=${TAILSCALE_AUTH_KEY}
      - TS_EXTRA_ARGS=--advertise-tags=tag:server
      - TS_STATE_DIR=/var/lib/tailscale
      - TS_SOCKET=/var/run/tailscale/tailscaled.sock
    volumes:
      - tailscale-state:/var/lib/tailscale
      - tailscale-socket:/var/run/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    network_mode: host
    restart: unless-stopped

  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    depends_on:
      - tailscale
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - tailscale-socket:/var/run/tailscale
    environment:
      - TAILSCALE_OAUTH_CLIENT_ID=${TAILSCALE_OAUTH_CLIENT_ID}
      - TAILSCALE_OAUTH_CLIENT_SECRET=${TAILSCALE_OAUTH_CLIENT_SECRET}

volumes:
  tailscale-state:
  tailscale-socket:
```

Set `TAILSCALE_AUTH_KEY` to authenticate the Tailscale container. Generate it in the Tailscale Admin Console under Settings -> Keys. The sidecar should advertise `tag:server` so it can satisfy the ACL auto-approver example below.

The sidecar uses `network_mode: host` so it can reach container IPs on any Docker network. On Docker Desktop this requires enabling host networking under Settings -> Resources -> Network. Alternatively, remove `network_mode: host` and attach the sidecar to the same Docker network as the containers you expose. On rootless Docker, prefer the shared-network form; host networking is limited in that mode.

### Platforms And Release Binaries

The image `ghcr.io/marvinvr/docktail` is published for `linux/amd64`, `linux/arm64` and `linux/arm/v7` (Raspberry Pi 2/3 and older 32-bit ARM NAS devices). Docker picks the right one automatically; the setups above work unchanged on all three. The same tags are mirrored to Docker Hub as `marvinvr/docktail` if you prefer pulling from there.

[GitHub releases](https://github.com/marvinvr/docktail/releases) newer than 1.8.3 also carry static Linux binaries for the same three architectures (`docktail_<version>_linux_amd64.tar.gz`, `…_linux_arm64.tar.gz`, `…_linux_armv7.tar.gz`) plus a `checksums.txt`. Use them to run DockTail directly on a Linux host instead of in a container:

```bash
VERSION=1.9.0  # a release that lists binaries under its assets
ARCH=amd64     # or arm64, armv7
curl -fsSLO "https://github.com/marvinvr/docktail/releases/download/${VERSION}/docktail_${VERSION}_linux_${ARCH}.tar.gz"
curl -fsSL "https://github.com/marvinvr/docktail/releases/download/${VERSION}/checksums.txt" | grep "_linux_${ARCH}.tar.gz" | sha256sum -c -
tar -xzf "docktail_${VERSION}_linux_${ARCH}.tar.gz" docktail
sudo install docktail /usr/local/bin/docktail
```

The binary behaves like the container and reads the same [environment variables](https://docktail.org/docs/reference/#environment-variables). Running outside a container it additionally needs:

- the `tailscale` CLI on the `PATH`, which the host's Tailscale install provides — the image bundles its own copy, the binary does not;
- access to the Docker socket (`/var/run/docker.sock`) and to the `tailscaled` socket at `/var/run/tailscale/tailscaled.sock`, the `tailscale` CLI's default, so run it as root or as a user in the `docker` group who is the Tailscale operator (`sudo tailscale set --operator=$USER`);
- something to keep it running, such as a systemd service with `Restart=always`, because DockTail [exits on purpose](https://docktail.org/docs/reference/#tailscale-socket-loss) when it loses the `tailscaled` socket.

Setting up the host's tailnet tag and the Tailscale admin side is the same as for [Tailscale On Host](https://docktail.org/docs/installation/#tailscale-on-host).


## Platform Guides

DockTail has two hard requirements wherever it runs:

- **A Docker Engine API.** DockTail discovers containers and reads their `docktail.*` labels through the Docker socket (or `DOCKER_HOST`). It only reads: it lists and inspects containers and follows container events, plus engine info, stats and log tails when [DockTail Cloud](https://docktail.org/docs/cloud/#docktail-cloud) is on.
- **A `tailscaled` socket it can write serve config to.** Either the host's daemon on Linux ([Tailscale On Host](https://docktail.org/docs/installation/#tailscale-on-host)) or a `tailscale/tailscale` container next to it ([Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar)). That daemon's node must carry a tag your policy lets advertise services ([ACL Configuration](https://docktail.org/docs/tailscale-admin/#acl-configuration)); `service hosts must be tagged nodes` in the logs means it does not.

A third, softer one: a **restart policy**. DockTail exits on purpose when it loses the Tailscale socket and relies on the restart to come back with a fresh mount ([Tailscale Socket Loss](https://docktail.org/docs/reference/#tailscale-socket-loss)).

The guides below say how each platform meets those, and how well each is known to work. The maintainers test DockTail on plain Linux Docker; everything else is based on user reports in the issue tracker and on the requirements above.

### Podman

Reported working. Podman serves a Docker-compatible API socket, and DockTail uses it like the Docker one: mount it at `/var/run/docker.sock`.

```bash
# Rootful Podman: the socket is /run/podman/podman.sock
sudo systemctl enable --now podman.socket

# Rootless Podman: the socket is /run/user/<uid>/podman/podman.sock
systemctl --user enable --now podman.socket
```

```yaml
services:
  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    restart: unless-stopped
    volumes:
      - /run/podman/podman.sock:/var/run/docker.sock:ro   # or /run/user/1000/podman/podman.sock
      - /var/run/tailscale:/var/run/tailscale
    environment:
      - TAILSCALE_OAUTH_CLIENT_ID=${TAILSCALE_OAUTH_CLIENT_ID}
      - TAILSCALE_OAUTH_CLIENT_SECRET=${TAILSCALE_OAUTH_CLIENT_SECRET}
```

- **One DockTail per `tailscaled`.** One instance watches one engine. If rootful and rootless Podman (or Podman and Docker) run on the same host, a second DockTail against the same `tailscaled` will fight the first over which services the node serves. `IGNORE_SERVICE_NAMES` on each instance keeps them apart; separate machines or VMs, each with its own Tailscale node, avoid the problem.
- **Rootless Podman** has the same two issues as [Rootless Docker](https://docktail.org/docs/installation/#rootless-docker): the host's `tailscaled` must trust the user (`tailscale set --operator`), and container IPs are often unreachable from the host, so use `docktail.service.direct=false` with a published port or run the Tailscale sidecar on the app's network.
- **SELinux.** On an enforcing host (Fedora, RHEL and derivatives), SELinux normally keeps a container from connecting to a host socket it has mounted; relaxing labelling for the DockTail container (`security_opt: [label=disable]`) is the usual fix. Not tested with DockTail.
- DockTail Cloud reporting with Podman has not been tested.

### Synology

Not tested by the maintainers. Container Manager (DSM 7.2 and later) is Docker, so its socket is at `/var/run/docker.sock` and a Compose file runs as a **Project**.

Use the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) setup, or start from [`docker-compose.sidecar.yaml`](https://github.com/marvinvr/docktail/blob/main/docker-compose.sidecar.yaml). DockTail has not been tried against the Tailscale package from the Package Center; the sidecar gives DockTail a daemon of its own instead of depending on where the package keeps its socket.

The sidecar needs `/dev/net/tun`. If the `tailscale` container logs that it is missing, follow Tailscale's Synology documentation for loading the TUN module at boot.

### Unraid

Reported to reach the host's `tailscaled` at `/var/run/tailscale` with the [Tailscale On Host](https://docktail.org/docs/installation/#tailscale-on-host) setup; the one problem reported was an untagged node (below). The rest of this section is not tested by the maintainers. DockTail can run as a Compose stack (Compose Manager plugin) or as a container added from the Docker tab:

| Setting | Value |
| --- | --- |
| Repository | `ghcr.io/marvinvr/docktail:latest` |
| Path | `/var/run/docker.sock` → `/var/run/docker.sock`, read-only |
| Path | `/var/run/tailscale` → `/var/run/tailscale` |
| Variables | `TAILSCALE_OAUTH_CLIENT_ID`, `TAILSCALE_OAUTH_CLIENT_SECRET` |

Make sure the container restarts on its own after it exits; if yours does not, add `--restart unless-stopped` under Extra Parameters.

- **Tag the Unraid node.** `Failed to add service ... service hosts must be tagged nodes` means the host is not tagged. Run `tailscale up --advertise-tags=tag:server` in the Unraid terminal and add the tag to your policy ([ACL Configuration](https://docktail.org/docs/tailscale-admin/#acl-configuration)).
- A `Warning: client version ... != tailscaled server version ...` line only says that the `tailscale` CLI in the image and the plugin's daemon are different versions; on its own it is not an error.
- Containers with their own address on a macvlan or ipvlan network (Unraid's `br0`) are not reachable from the host by default, and in direct mode it is the host's `tailscaled` that connects to them. Keep exposed apps on a bridge network, or enable host access to custom networks in Unraid's Docker settings.

### TrueNAS SCALE

Not tested by the maintainers. TrueNAS SCALE 24.10 (Electric Eel) and later run apps on Docker, so DockTail can be installed as a custom app from YAML. Releases before 24.10 run apps on Kubernetes and are not supported (see [Kubernetes](https://docktail.org/docs/platforms/#kubernetes)).

Paste the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) Compose file as the custom app's YAML, so DockTail and its `tailscaled` are deployed together. The Docker socket is at `/var/run/docker.sock`. Apps you expose must be reachable from the sidecar: it runs with host networking, which reaches container IPs on the host's Docker networks.

### macOS And Windows

Supported with the [Tailscale Sidecar](https://docktail.org/docs/installation/#tailscale-sidecar) only. The Tailscale app on macOS and Windows does not expose a Unix socket, and Docker Desktop, OrbStack and Colima run containers in a Linux VM that cannot mount host Unix sockets anyway. `dial unix /var/run/tailscale/tailscaled.sock: connect: no such file or directory` is the symptom of trying the host setup.

- The sidecar needs its own auth key (`TAILSCALE_AUTH_KEY`) in addition to DockTail's OAuth credentials, and joins the tailnet as its own device.
- The sidecar uses `network_mode: host`. On Docker Desktop, enable host networking under Settings -> Resources -> Network, or drop that line and attach the sidecar to the same Docker network as the apps you expose.
- With DockTail Cloud, host vitals and disk usage describe the Linux VM the containers run in, not the Mac or PC.

### Docker Swarm

No native Swarm support: DockTail reads **container** labels from the engine it is connected to, so it sees only the tasks running on its own node and ignores service-level `deploy.labels`. The layout below is based on the one users reported working on multi-node clusters in [issue #43](https://github.com/marvinvr/docktail/issues/43):

- Run DockTail as a `global` service, so every node has one, each with its own `tailscaled` — installed on the host, or a `global` sidecar as below. Each node joins the tailnet as a tagged device.
- Put the `docktail.*` labels under the service's top-level `labels:`, which Swarm applies to each task container, not under `deploy.labels`.
- Every node that runs a replica advertises the service, and Tailscale Services routes each client to one of the advertising hosts.
- Allow at most one replica of a labelled service per node (`deploy.placement.max_replicas_per_node: 1`, or `mode: global`). Two replicas on one node claim the same service name and port, which DockTail treats as a conflict and does not resolve ([Service Name Conflicts Between Containers](https://docktail.org/docs/labels/#service-name-conflicts-between-containers)).
- Avoid `update_config.order: start-first` for the `tailscale` service. It briefly runs two daemons on the same node and state volume; the working reports use the default order.

```yaml
services:
  tailscale:
    image: tailscale/tailscale:latest
    environment:
      - TS_AUTHKEY=${TAILSCALE_AUTH_KEY}   # a reusable key: every node uses it
      - TS_EXTRA_ARGS=--advertise-tags=tag:server
      - TS_STATE_DIR=/var/lib/tailscale
      - TS_SOCKET=/var/run/tailscale/tailscaled.sock
      - TS_USERSPACE=false
    volumes:
      - tailscale-state:/var/lib/tailscale
      - tailscale-socket:/var/run/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    deploy:
      mode: global

  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - tailscale-socket:/var/run/tailscale
    environment:
      - TAILSCALE_OAUTH_CLIENT_ID_FILE=/run/secrets/tailscale_oauth_client_id
      - TAILSCALE_OAUTH_CLIENT_SECRET_FILE=/run/secrets/tailscale_oauth_client_secret
    secrets:
      - tailscale_oauth_client_id
      - tailscale_oauth_client_secret
    deploy:
      mode: global

  whoami:
    image: traefik/whoami:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=whoami"
      - "docktail.service.port=80"
    deploy:
      replicas: 2
      placement:
        max_replicas_per_node: 1

volumes:
  tailscale-state:
  tailscale-socket:

secrets:
  tailscale_oauth_client_id:
    external: true
  tailscale_oauth_client_secret:
    external: true
```

Named volumes are local to each node, so each node's `tailscale` task keeps its own state and shares its socket only with the DockTail task on the same node. The sidecar here is not on the host network; it reaches the apps over the stack's overlay network, so deploy them in the same stack or attach them to a shared network.

### Kubernetes

Not supported, and there is no Helm chart. Kubernetes nodes run containerd or CRI-O without a Docker Engine API for DockTail to watch, and workloads are described by pod annotations and Services rather than Docker labels. For Kubernetes, use Tailscale's own Kubernetes operator.


## Hardening

DockTail needs two sockets, and both are powerful. This section says what they grant and how to narrow it. None of it is required, and none of it is covered by DockTail's automated tests; what DockTail needs is taken from its source.

### The Docker Socket

Every example mounts `/var/run/docker.sock:ro`. The `:ro` flag makes the bind mount read-only, which does not matter for a socket: it does not stop anyone from connecting to it, and a connection gets the full Docker API — start, exec, create privileged containers. Treat access to the Docker socket as root on the host.

DockTail itself only reads from it: it lists and inspects containers and follows container events, and with [DockTail Cloud](https://docktail.org/docs/cloud/#docktail-cloud) on it also reads engine info and version, one-shot container stats, and log tails. It never creates, starts, stops or execs anything. To make that a guarantee rather than a property of the code, put a read-only proxy in front of the socket.

### Read-Only Socket Proxy

[`tecnativa/docker-socket-proxy`](https://github.com/Tecnativa/docker-socket-proxy) allows only the API sections you enable and, with `POST=0` (its default), only `GET` and `HEAD` requests. DockTail needs `CONTAINERS` on top of the sections the proxy allows by default (`EVENTS`, `PING`, `VERSION`), and `INFO` as well when DockTail Cloud is on:

```yaml
services:
  docker-socket-proxy:
    image: tecnativa/docker-socket-proxy:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - CONTAINERS=1 # list, inspect, stats, logs
      - INFO=1       # DockTail Cloud only: engine ID and host specs
      - EVENTS=1     # default; container start/stop/die/restart/oom/health events
      - PING=1       # default; API version negotiation
      - VERSION=1    # default
      - POST=0       # default; read-only
    networks:
      - docker-api

  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    restart: unless-stopped
    depends_on:
      - docker-socket-proxy
    volumes:
      - /var/run/tailscale:/var/run/tailscale
    environment:
      - DOCKER_HOST=tcp://docker-socket-proxy:2375
      - TAILSCALE_OAUTH_CLIENT_ID=${TAILSCALE_OAUTH_CLIENT_ID}
      - TAILSCALE_OAUTH_CLIENT_SECRET=${TAILSCALE_OAUTH_CLIENT_SECRET}
    networks:
      - default    # outbound: the Tailscale API and DockTail Cloud
      - docker-api

networks:
  docker-api:
    internal: true
```

- Keep the proxy on an `internal` network that only DockTail joins, and never publish port 2375: anyone who can reach it can read what DockTail reads. DockTail itself also stays on a normal network, since it calls the Tailscale API (and DockTail Cloud) over the internet.
- Read-only is not the same as harmless. `CONTAINERS=1` allows every `GET` under `/containers`: inspecting any container (including environment variables that may hold other apps' secrets), reading its logs, and downloading files from it through the archive and export endpoints.
- If the proxy closes the event stream, DockTail logs `Docker event stream error` and reconnects after five seconds; the periodic reconcile covers anything that changed in between.

### Container Privileges

The image runs DockTail as root. It needs no Linux capabilities for its own work — it talks to Unix sockets (or the proxy above), reads files, and runs the `tailscale` CLI against `tailscaled`'s socket — so you can drop them all and block privilege escalation:

```yaml
services:
  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
```

Dropping `CAP_DAC_OVERRIDE` also makes root subject to ordinary file permission bits. Credential files loaded through `*_FILE` or `FILE__*` must then be owned by root or readable by everyone inside the container; Docker Swarm secrets are, by default. A `0600` file owned by your own user, bind-mounted from the host, is not, and DockTail exits at startup when it cannot read it.


## Tailscale Admin Setup

DockTail can advertise services locally without Tailscale API credentials, but OAuth or API key credentials allow it to create service definitions automatically in the Tailscale Admin Console.

### OAuth Credentials

OAuth is recommended. It enables automatic service creation and avoids expiring API keys.

1. Open Tailscale Admin Console -> Settings -> Trust credentials.
2. Create an OAuth client scoped to your server tag, for example `tag:server`.
3. Grant these permissions:
   - General -> Services: Write (and specify required tag)
   - Devices -> Core: Write
   - Keys -> Auth Keys: Write (only when using the sidecar method)

   These same permissions also cover the optional `DELETE_UNUSED_SERVICES` cleanup, which lists Services, inspects their advertising hosts, and deletes the ones no host advertises. They also cover [DockTail Cloud](https://docktail.org/docs/cloud/#tailnet-health) tailnet health, which reads the same advertising-host data to tell an unapproved or unadvertised service from a broken container. No extra scope is required, and the credentials never leave the host.
4. Add the credentials to DockTail:

```yaml
environment:
  - TAILSCALE_OAUTH_CLIENT_ID=your-client-id
  - TAILSCALE_OAUTH_CLIENT_SECRET=your-client-secret
```

Or mount the credentials as files:

```yaml
services:
  docktail:
    volumes:
      - ./secrets:/run/secrets/docktail:ro
    environment:
      - FILE__TAILSCALE_OAUTH_CLIENT_ID=/run/secrets/docktail/tailscale_oauth_client_id
      - TAILSCALE_OAUTH_CLIENT_SECRET_FILE=/run/secrets/docktail/tailscale_oauth_client_secret
```

If OAuth and API key credentials are both configured, DockTail uses OAuth.

### API Key

An API key also enables automatic service creation, but Tailscale API keys expire.

```yaml
environment:
  - TAILSCALE_API_KEY=tskey-api-...
```

API keys can also be loaded from `FILE__TAILSCALE_API_KEY` or `TAILSCALE_API_KEY_FILE`.

### Manual Mode

DockTail can run without credentials. It advertises services locally through the Tailscale CLI, but you must manually create service definitions in the Tailscale Admin Console and configure ACL auto-approvers. Without credentials, DockTail Cloud also cannot report tailnet health, since it has no way to read the control plane.

### ACL Configuration

Services require tag definitions in `tagOwners` and an `autoApprovers.services` rule that allows the host to advertise container services.

```json
{
  "tagOwners": {
    "tag:server": ["autogroup:admin"],
    "tag:container": ["tag:server"]
  },
  "autoApprovers": {
    "services": {
      "tag:container": ["tag:server"]
    }
  }
}
```

`tag:server` is assigned to the host machine or sidecar auth key that runs DockTail. `tag:container` is the default tag DockTail assigns to services it creates.

If you manage ACLs through GitOps, both tags must exist in `tagOwners`; otherwise Tailscale rejects references to undefined tags.

### Funnel ACL

Funnel needs an extra grant on top of the service rules above. Tailscale only lets a node expose public Funnel endpoints if it has the `funnel` node attribute. DockTail runs Funnel on the node running its `tailscaled`, which is tagged `tag:server` in both the host and sidecar setups, so grant the attribute to `tag:server`:

```json
{
  "nodeAttrs": [
    {
      "target": ["tag:server"],
      "attr": ["funnel"]
    }
  ]
}
```

Notes:

- Grant `funnel` to `tag:server` (the DockTail host or sidecar), not `tag:container`. `tag:container` is the virtual service tag, not a real device, so it cannot run Funnel.
- `autoApprovers.services` only approves service advertisement inside the tailnet. It does not grant Funnel.
- The public Funnel URL is the machine hostname (`https://<host>.<tailnet>.ts.net`), not the service URL (`https://<service>.<tailnet>.ts.net`). Test it from a device that is not on your tailnet.

### Approve Services

The first time a new service is advertised, it may need approval in the Tailscale Admin Console Services tab. After approval, the service continues to work across container restarts. OAuth or API key credentials can create service definitions automatically, but first approval may still be required depending on your ACL policy.


## Labels

DockTail watches containers with `docktail.*` labels. Each labeled container can become a private Tailscale service, a public Funnel, or both. DockTail does not run your application containers; it only observes them and configures Tailscale.

### Direct Container IP Proxying

By default, DockTail proxies directly to container IPs on the Docker network. No Docker port publishing is required.

```yaml
services:
  myapp:
    image: nginx:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=myapp"
      - "docktail.service.port=80"
```

Set `docktail.service.direct=false` to use published host ports instead. Use this for legacy setups, or when host `tailscaled` cannot reach container IPs (common with [rootless Docker](https://docktail.org/docs/installation/#rootless-docker)).

### Service Labels

| Label | Required | Default | Description |
| --- | --- | --- | --- |
| `docktail.service.enable` | Yes | - | Enable a private Tailscale service for the container. |
| `docktail.service.name` | Yes | - | Service name, such as `web` or `api`. |
| `docktail.service.port` | Yes | - | Backend container port to proxy to. |
| `docktail.service.description` | No | - | Human-readable description shown for the service in the Tailscale admin panel. Requires API credentials (synced to the Service definition's `comment`). |
| `docktail.service.direct` | No | `true` | Proxy directly to container IP instead of requiring a published host port. Set `false` when host `tailscaled` cannot reach container IPs (rootless Docker). |
| `docktail.service.network` | No | `bridge` or first available | Docker network used for direct container IP detection. |
| `docktail.service.protocol` | No | Smart | Backend protocol. |
| `docktail.service.service-port` | No | Smart | Port Tailscale listens on. |
| `docktail.service.service-protocol` | No | Smart | Tailscale-facing protocol. |
| `docktail.service.path` | No | `/` | URL path for HTTP(S) Serve traffic. Must start with `/`; not valid for TCP services. |
| `docktail.service.proxy-protocol` | No | off | PROXY protocol version (`1` or `2`) prepended on TCP forwards so the backend sees the tailnet client address. Only valid with `service-protocol` `tcp` or `tls-terminated-tcp`. |
| `docktail.tags` | No | `tag:container` | Comma-separated service tags. Labels are the source of truth; see the note below. |

Tags are synced to the tailnet Service definition through the Tailscale API and require API credentials. Labels are authoritative: DockTail reconciles tags on every cycle, so tags edited by hand in the Tailscale admin console are reverted to the label-declared set on the next reconcile. Containers without a `docktail.tags` label use `DEFAULT_SERVICE_TAGS`.

Smart defaults:

- `docktail.service.protocol` defaults to `https` when the backend port is `443`; otherwise it defaults to `http`.
- `docktail.service.service-port` defaults to `443` when `service-protocol` is `https`; otherwise it defaults to `80`.
- `docktail.service.service-protocol` defaults to `https` when the service port is `443`, to `tcp` when the backend protocol is TCP, and otherwise to `http`.
- `docktail.service.path` defaults to `/` and is passed to `tailscale serve --set-path`. Changing or removing the label reconciles the old handler before advertising the new path.
- `docktail.service.proxy-protocol` is opt-in and off by default. The backend must understand PROXY protocol; sending the header to something that does not (Postgres, Redis, raw TCP apps) will break the connection. Set it to `2` unless you specifically need version `1`. The label is rejected on HTTP/HTTPS services because Tailscale only supports PROXY protocol for TCP forwarding.

To expose an HTTP(S) service below a custom path:

```yaml
labels:
  - "docktail.service.enable=true"
  - "docktail.service.name=api"
  - "docktail.service.port=8000"
  - "docktail.service.path=/api"
```

### Multiple Services From One Container

A single container can expose multiple separate Tailscale services using numbered labels:

```yaml
services:
  gluetun:
    image: qmcgaw/gluetun:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=qbittorrent"
      - "docktail.service.port=8000"
      - "docktail.service.1.name=bitmagnet"
      - "docktail.service.1.port=8001"
```

Each indexed service requires its own `name` and `port`. Per-index overridable labels are `name`, `port`, `service-port`, `protocol`, `service-protocol`, `path`, `proxy-protocol`, and `description`. Tags and network settings are inherited from the primary service config.

### Service Name Conflicts Between Containers

Several containers may share a service name as long as each uses a different `service-port`. A given service name and `service-port` pair can only be backed by one container per DockTail host. If two containers declare the same pair, for example after copy-pasting labels:

```yaml
services:
  app:
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=web"
      - "docktail.service.port=3000"
  app-copy:
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=web" # conflicts with app on svc:web:80
      - "docktail.service.port=3000"
```

DockTail does not pick a winner. It logs `Service endpoint conflict` with both container names, leaves that endpoint exactly as it is currently served (a container that already serves it keeps it; if nobody does, it stays unserved), pauses tag and description syncing and the removal of stale ports for that service name, and reports the reconciliation as failed until only one container claims the pair. All other services keep reconciling normally.

This is a guard against misconfiguration, not a tenant isolation boundary: DockTail trusts every container that can carry `docktail.*` labels, and once the original container stops, the remaining one becomes the sole claimant and is served.

### Funnel Labels

Funnel exposes a service to the public internet. It can be used together with a private DockTail service or on its own for funnel-only containers.

| Label | Required | Default | Description |
| --- | --- | --- | --- |
| `docktail.funnel.enable` | Yes | `false` | Enable Tailscale Funnel. |
| `docktail.funnel.port` | Yes | - | Backend container port for Funnel traffic. |
| `docktail.funnel.funnel-port` | No | `443` | Public Funnel port. HTTPS/HTTP Funnel supports `443`, `8443`, or `10000`. |
| `docktail.funnel.protocol` | No | `https` | Funnel protocol: `http`, `https`, `tcp`, or `tls-terminated-tcp`. |
| `docktail.funnel.path` | No | `/` | HTTP(S) Funnel path. Must start with `/`. |

Funnel notes:

- HTTP(S) Funnels can share a public port when each Funnel uses a different `docktail.funnel.path`.
- TCP and TLS-terminated TCP Funnels support only one active Funnel per public port on a node.
- `docktail.funnel.path` is only valid for HTTP(S) Funnels.
- Funnel URLs use the machine hostname, not the Tailscale service name.
- Funnel-only containers can omit `docktail.service.enable` and other `docktail.service.*` labels.
- `docktail.service.direct` and `docktail.service.network` still control how DockTail reaches the backend for Funnel traffic.

### DockTail Cloud Labels

With [DockTail Cloud](https://docktail.org/docs/cloud/#docktail-cloud) enabled, `docktail.cloud.*` labels declare how Cloud monitors a container, next to the rest of its configuration. They change nothing about what DockTail serves on your tailnet, and are ignored when Cloud is not enabled.

| Label | Values | Description |
| --- | --- | --- |
| `docktail.cloud.ignore` | `true` / `false` | `true` keeps the container out of Cloud monitoring: it is not reported as a service, is never checked, captures no logs, and cannot be watched. It still appears in the host's container inventory, marked as ignored by label, and its Docker events (start, stop, exit) still show in the activity log like any other container's. |
| `docktail.cloud.logs` | `off` | Never capture incident log excerpts for this container. Capture can only be switched *on* in the Cloud dashboard. |
| `docktail.cloud.check.kind` | `tcp` / `http` | Kind of local check. Without the label, the dashboard's setting applies, else `tcp`. |
| `docktail.cloud.check.path` | `/path` | Path the HTTP check requests. Must start with `/`. Implies `check.kind=http`. |
| `docktail.cloud.check.expect-status` | `100`–`599` | The only HTTP status that counts as up. Without it, any status below 500 is up. Implies `check.kind=http`. |

```yaml
labels:
  - "docktail.service.enable=true"
  - "docktail.service.name=api"
  - "docktail.service.port=8000"
  - "docktail.cloud.check.path=/healthz"
  - "docktail.cloud.logs=off"
```

A label wins over the dashboard for the setting it names: while `docktail.cloud.logs=off` is set, the dashboard shows that service's log capture as set by label and dashboard changes to it do not apply. Settings without a label keep their dashboard value.

The check always targets the port DockTail already probes for the service; labels choose only how it is checked, never where. Cloud labels apply to every service a container publishes, including [numbered services](https://docktail.org/docs/labels/#multiple-services-from-one-container) — except that a service whose backend protocol is `tcp` or `tls-terminated-tcp` keeps its TCP check whatever the HTTP check labels say. An invalid value (for example `docktail.cloud.check.kind=udp`) or an unknown `docktail.cloud.*` label is logged as a warning and ignored. `check.path` and `check.expect-status` are ignored when `check.kind=tcp`.

Adding `docktail.cloud.ignore=true` to a container Cloud already monitors reads as that service being removed from the catalog; removing the label brings it back.


## Examples

These examples show the labels you add to application containers. They assume DockTail itself is already running on the same Docker host.

### Web Application

```yaml
services:
  nginx:
    image: nginx:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=web"
      - "docktail.service.port=80"
```

Access it at `http://web.your-tailnet.ts.net`.

### Service With A Description

Add a description to label the service in the Tailscale admin panel. Requires API credentials (OAuth or API key), which DockTail syncs to the Service definition's `comment`.

```yaml
services:
  linkding:
    image: sissbruecker/linkding:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=linkding"
      - "docktail.service.port=9090"
      - "docktail.service.description=Bookmark Manager"
```

### HTTPS With Auto TLS

```yaml
services:
  api:
    image: myapi:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=api"
      - "docktail.service.port=3000"
      - "docktail.service.service-port=443"
```

Access it at `https://api.your-tailnet.ts.net`.

### HTTPS with TCP (SSH)

```yaml
services:
  forgejo:
    image: codeberg.org/forgejo/forgejo:latest
    labels:
        - "docktail.service.enable=true"
        - "docktail.service.name=forgejo"
        - "docktail.service.port=3000"
        - "docktail.service.service-port=443"
        - "docktail.service.1.enable=true"
        - "docktail.service.1.name=forgejo"
        - "docktail.service.1.port=2222"
        - "docktail.service.1.protocol=tcp"
        - "docktail.service.1.service-port=22"
```

Access 
- https at `https://forgejo.your-tailnet.ts.net` 
- ssh at `ssh -T -l git forgejo.your-tailnet.ts.net`

### Database Over TCP

```yaml
services:
  postgres:
    image: postgres:16
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=db"
      - "docktail.service.port=5432"
      - "docktail.service.protocol=tcp"
      - "docktail.service.service-port=5432"
```

### Reverse Proxy With Client IPs (PROXY Protocol)

TCP services normally hide the tailnet client address: the backend sees tailscaled's own IP. Set `docktail.service.proxy-protocol` so Tailscale prepends a [PROXY protocol](https://www.haproxy.com/blog/use-the-proxy-protocol-to-preserve-a-clients-ip-address) header. The backend (Traefik, Caddy, HAProxy, nginx, and similar) must be configured to accept it.

```yaml
services:
  traefik:
    image: traefik:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=traefik"
      - "docktail.service.port=443"
      - "docktail.service.protocol=tcp"
      - "docktail.service.service-protocol=tcp"
      - "docktail.service.service-port=443"
      - "docktail.service.proxy-protocol=2"
      - "docktail.service.direct=false"
```

Without this label, access logs, rate limits, and IP allowlists on the reverse proxy only see tailscaled. HTTP/HTTPS DockTail services cannot use this label; Tailscale rejects PROXY protocol for those modes.

### Custom Docker Network

```yaml
services:
  app:
    image: myapp:latest
    networks:
      - backend
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=app"
      - "docktail.service.port=3000"
      - "docktail.service.network=backend"

networks:
  backend:
```

### Legacy Published-Port Mode

Use published host ports when you cannot proxy to the container IP. That includes older setups and [rootless Docker](https://docktail.org/docs/installation/#rootless-docker) with host Tailscale, where `tailscaled` often cannot reach container IPs.

```yaml
services:
  app:
    image: myapp:latest
    ports:
      - "8080:3000"
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=app"
      - "docktail.service.port=3000"
      - "docktail.service.direct=false"
```

### Private Service Plus Public Funnel

```yaml
services:
  website:
    image: nginx:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=website"
      - "docktail.service.port=80"
      - "docktail.service.service-port=443"
      - "docktail.funnel.enable=true"
      - "docktail.funnel.port=80"
```

Tailnet URL: `https://website.your-tailnet.ts.net`

Public Funnel URL: `https://your-machine.your-tailnet.ts.net`

### Funnel-Only Public Proxy

```yaml
services:
  immich-public-proxy:
    image: ghcr.io/immich-app/immich-public-proxy:latest
    labels:
      - "docktail.funnel.enable=true"
      - "docktail.funnel.port=3000"
      - "docktail.funnel.funnel-port=8443"
```

Access it publicly at `https://your-machine.your-tailnet.ts.net:8443`.

### Public Funnel Mounted At A Path

```yaml
services:
  webhook:
    image: my-webhook:latest
    labels:
      - "docktail.funnel.enable=true"
      - "docktail.funnel.port=3000"
      - "docktail.funnel.funnel-port=443"
      - "docktail.funnel.path=/webhook"
```

Access it publicly at `https://your-machine.your-tailnet.ts.net/webhook`.


## DockTail Cloud

DockTail Cloud is optional, opt-in monitoring for DockTail-managed services across one or more hosts. It is a hosted dashboard that watches what DockTail exposes and tells you *why* something is unreachable.

[Explore DockTail Cloud](https://docktail.org/cloud/) or [open the dashboard](https://cloud.docktail.org/login).

DockTail Cloud is a paid service; the agent code that reports to it is the same open-source DockTail.

- **Account.** You sign up at [cloud.docktail.org](https://cloud.docktail.org/login) yourself. An AI agent cannot create the account, the workspace or the subscription for you; once they exist, it can help with everything else.
- **Plans.** Homelab, Team and Business, priced by the number of monitored hosts. Current prices and host limits are on [plans and pricing](https://docktail.org/cloud/#pricing).
- **Trial.** Homelab and Team start with a 30-day free trial. It needs a card and turns into the paid plan when it ends unless you cancel. Business starts at its regular price.
- **No plan, no hosts.** A workspace connects no host until it has a plan or a running trial; before that the dashboard shows demo data.

### What You Get

- **One view of every host and service.** The full catalog of DockTail-managed services, plus a read-only inventory of the host's other containers, with health history.
- **The useful distinction.** A plain uptime check stops at "down." Cloud already has the Docker and Tailscale context, so it separates a *container* problem (exit code, Docker OOM event, restart loop) from an *exposure* problem (the container answers locally, but the Tailscale control plane says the service is awaiting approval, not advertised by this host, or gone) from a *host* problem (the box stopped sending heartbeats).
- **Incidents with the evidence attached.** Docker failure events and a bounded log tail captured at the moment of failure, so you start from the reason instead of from a graph.
- **Alerts and recoveries.** Notification when a service breaks and when it comes back — including hosts that drop off entirely, since detection runs in Cloud rather than on the box.

Reporting rides along with the normal agent — there is no separate binary. The same DockTail container gains cloud reporting when a workspace key is present, and stays completely inert without one — the only trace is a single info line at startup noting that DockTail Cloud is not connected.

### How To Enable

Before you start:

- **Tailscale API credentials.** Configure `TAILSCALE_OAUTH_CLIENT_ID`/`TAILSCALE_OAUTH_CLIENT_SECRET` (or `TAILSCALE_API_KEY`) first, as in [Tailscale Admin Setup](https://docktail.org/docs/tailscale-admin/#tailscale-admin-setup). Cloud's [tailnet vantage](https://docktail.org/docs/cloud/#tailnet-health) reads the control plane through them, and one credentialed host per tailnet is enough. With none, Cloud reports "no Tailscale credentials" instead of approval and advertisement state; everything else still works.
- **A working DockTail.** The host is tagged, and its services already show up on the tailnet without Cloud.
Then:

1. Sign in at [cloud.docktail.org](https://cloud.docktail.org/login), creating your account if you do not have one.
2. Create a workspace.
3. Choose a plan, or start the 30-day trial on Homelab or Team.
4. Copy the workspace key (`dtc_...`) the onboarding shows under **Connect your first host**. Later keys are created under [Settings → Agent keys](https://cloud.docktail.org/settings/agent-keys).
5. Set `DOCKTAIL_CLOUD_KEY` on the DockTail agent and recreate the container (`docker compose up -d`). Do this within the key's enrollment window, one hour by default (see [Identity](https://docktail.org/docs/cloud/#identity)).
6. The host appears on [Hosts](https://cloud.docktail.org/hosts), and [`docktail health`](https://docktail.org/docs/reference/#health-check) reports `cloud connected`.

That is the only configuration — the cloud endpoint is built into the agent. A complete Compose file with it is [`docker-compose.cloud.yaml`](https://github.com/marvinvr/docktail/blob/main/docker-compose.cloud.yaml).

```yaml
services:
  docktail:
    image: ghcr.io/marvinvr/docktail:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/run/tailscale:/var/run/tailscale
    environment:
      - TAILSCALE_OAUTH_CLIENT_ID=${TAILSCALE_OAUTH_CLIENT_ID}
      - TAILSCALE_OAUTH_CLIENT_SECRET=${TAILSCALE_OAUTH_CLIENT_SECRET}
      # Optional. Enables DockTail Cloud reporting.
      - DOCKTAIL_CLOUD_KEY=${DOCKTAIL_CLOUD_KEY}
```

With no key set, no connection is opened and DockTail runs exactly as before.

`docktail health` reports the connection state (`connecting`, `connected`,
`disconnected`, `rejected` with the reason, or `failed` when the module could
not start, for example with a malformed key) without ever making the container unhealthy; see
[Health Check](https://docktail.org/docs/reference/#health-check). When the cloud accepts the
connection the agent also compares its clock with the cloud's and warns if they
are more than 60 seconds apart, since event and check times would then be off;
enable time sync (NTP) on the host.

If Cloud marks a host as unmonitored (for example, the host sits past the
workspace's host cap), the agent keeps the connection open with heartbeats and
occasional catalog snapshots and pauses checks, Docker events, metrics, tailnet
state, tailnet-health answers, and log excerpts. Cloud pushes an updated configuration over the same
connection when that changes; the agent does not need a restart.

### Cloud Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
| `DOCKTAIL_CLOUD_KEY` | - | Workspace key (`dtc_...`) from the cloud dashboard. Enables reporting. Inert when unset. |
| `DOCKTAIL_LOG_LEVEL` | `info` | Read, but currently has no effect: the cloud module logs at the level `LOG_LEVEL` sets. |
| `DOCKTAIL_CHECK_INTERVAL` | `30s` | How often local-vantage checks run (5s–5m). |
| `DOCKTAIL_HOST_ROOT` | `/host` | Where the host's root filesystem is bind-mounted, for whole-host disk usage (see [Disk Usage](https://docktail.org/docs/cloud/#disk-usage)). Only used when that path exists. |

For local development, `DOCKTAIL_CLOUD_URL` overrides the built-in endpoint.
Plaintext `ws://` is accepted only for loopback endpoints unless
`DOCKTAIL_CLOUD_ALLOW_INSECURE=true` is also set. Do not use that escape hatch
in production; non-loopback production endpoints must use `wss://`.

### What It Sends

The hosted control plane (the dashboard and ingest service behind `wss://ingest.docktail.org`) is a separate, proprietary product. The reporting module in this repository sends operational metadata and bounded incident log tails to it over an outbound-only WebSocket Secure (WSS) connection.

When enabled, the agent reports the following operational data:

- Periodic snapshots of DockTail-managed services, including stopped containers, plus refreshes after successful reconciles.
- A read-only inventory of the host's **other** containers — the ones *not* published with `docktail.*` labels, plus any labelled `docktail.cloud.ignore=true`, including stopped ones — with name, image, state/health, ports, and live CPU/memory. These containers are not actively probed; they are listed on the dashboard so you can see the host's whole Docker footprint, and can be explicitly watched for Docker-event-driven incidents and alerts.
- Docker failure events, including container exit codes, out-of-memory (OOM) kills, health-status changes, and restart loops. Docker reports an OOM event whenever the kernel kills *any* process in a container, so the agent also says whether the container kept running. A killed child process (a worker, a transcoder) in a container that stays up is recorded as an event, not reported as the service going down; only an OOM kill that stops the container is.
- Local-vantage check results. Checks default to TCP; cloud-managed config or the container's own [`docktail.cloud.check.*` labels](https://docktail.org/docs/labels/#docktail-cloud-labels) may select HTTP, a relative path, and expected status, but the destination always comes from the agent's local service discovery. HTTP checks are plain HTTP to the container and do not follow redirects; with an expected status set, only that exact status passes, otherwise any answer below 500 counts as up. Each probe allows up to 15 seconds, so a slow service that still answers is reported with its latency (Cloud can flag it as degraded) rather than as down.
- Each service's valid `docktail.cloud.*` label values, so the dashboard can show which settings are set by label.
- Whole-host vitals, sampled every 30 seconds: CPU, memory and swap usage, load average, temperature where the machine has sensors, and per-filesystem disk usage (mount point, total, used, and available bytes, at most 16 filesystems). These describe the machine, not the containers; nothing is stored as history, each report replaces the last. Disk is read on Linux only, from `/proc/mounts` and `statfs`, and covers real filesystems only — network mounts such as NFS and CIFS are deliberately skipped, so an unresponsive NAS can never stall reporting. Docker inside a Proxmox LXC needs no extra setup: the container's `/proc` shows the physical node, so the agent reports the CT's memory instead — its limit as Docker reports it, and as used the combined usage of all running containers excluding active and inactive file cache (without the CT's few non-container processes). This prevents cache-heavy reads from triggering false memory-pressure alerts. If full file-cache counters are unavailable, each container falls back to its working set, as shown by `docker stats`. Load average and swap are omitted there, because only the node's figures are visible.
- Tailscale control-plane service state, when Cloud asks for it (see [Tailnet Health](https://docktail.org/docs/cloud/#tailnet-health)).
- For a Funnel-exposed service, this node's MagicDNS name — the public address its Funnel answers on (see [Public Health](https://docktail.org/docs/cloud/#public-health)).
- Bounded incident log excerpts. Cloud enables this by default and you can turn it off for the whole workspace or for an individual service, in the dashboard or with the `docktail.cloud.logs=off` label; the agent captures nothing while the mode is off. Before sending, the agent best-effort redacts common Authorization/Bearer credentials, passwords, tokens, API keys, credential URLs, JWTs, and private-key blocks, then applies the 40-line/8-KiB caps. Redaction cannot recognize every application-specific secret, so turn capture off if your logs carry secrets those patterns will not match.

If the connection to Cloud drops, the agent keeps watching Docker and buffers the
failure events it sees — plus the log tail for each, captured at the moment of the
failure rather than on reconnect — then replays them with their original timestamps
once the link is back. A container that crashes and recovers during a network blip
or a Cloud deployment still produces an incident and an alert. The buffer is held in
memory only, is capped (1024 frames / 1 MiB, newest kept), and frames older than an
hour are discarded rather than replayed: by then Cloud has already alerted that the
host stopped reporting, so re-raising hours-old container failures would only add
noise. Periodic data — snapshots, check results, host metrics — is not buffered,
since the next report replaces it anyway.

### Disk Usage

With the standard setup above — only the Docker socket mounted — the agent sees
one filesystem: its own container root. That is less limiting than it sounds,
because the container root passes through to the filesystem that actually holds
`/var/lib/docker`, which on a normal install is the host's root filesystem and
the usual reason a self-hosted box runs out of space. Cloud reports it as `/`.

To see every filesystem the host has — a separate `/mnt/data`, a media disk, a
backup volume — bind-mount the host's root into the container read-only:

```yaml
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # Optional. Reports disk usage for every host filesystem, not just the
      # one backing /var/lib/docker.
      - /:/host:ro
```

The agent then reads the host's mount table and reports each filesystem under
its real path (`/mnt/data`, not `/host/mnt/data`). The mount is read-only and
used for nothing else; if you prefer a different mount point, set
`DOCKTAIL_HOST_ROOT` to it. Without it, nothing else changes — every other
metric is already the host's.

### What It Never Does

- No remote command execution, deployment, or shell access. The protocol is metadata-only and has no exec, deploy, or shell message types.
- It never executes anything on the host on behalf of the cloud.
- Cloud configuration cannot select an arbitrary network destination; checks are bound to services discovered locally from Docker. A tailnet-health request carries only service names the agent itself published, and carries no credentials.
- Tailscale credentials stay on the host. Cloud never receives an OAuth client, an API key, or a Tailscale token — only the metadata the agent reads with them.
- The connection is outbound only; the agent dials the ingest endpoint and nothing dials in.

### Tailnet Health

Cloud's tailnet vantage answers one question: does the Tailscale *control plane*
agree that this host is advertising the service and that the service is approved?
Answering it needs Tailscale API credentials, so it only works when
`TAILSCALE_OAUTH_CLIENT_ID`/`TAILSCALE_OAUTH_CLIENT_SECRET` or
`TAILSCALE_API_KEY` is already configured (see
[Tailscale Admin Setup](https://docktail.org/docs/tailscale-admin/#tailscale-admin-setup)). No new
credential, and none of them ever leaves the host: Cloud asks a question, the
agent reads the Tailscale API and answers with metadata.

It reads the control plane rather than the host's own `tailscale serve` config
because serve state only says "this host believes it is serving." It cannot see
that the service is waiting for approval in the Admin Console, that its
definition was deleted, or that the advertisement never reached the control
plane — cases where the host looks perfectly healthy and nobody can reach the
service.

This is an approval and advertisement oracle, not a reachability ping. Tailscale
exposes no health or liveness probe for a service, so a service Cloud reports as
`connected` is one the control plane considers advertised and approved — nothing
more. Actual reachability still comes from the local vantage and, for Funnel
services, the public one below.

Cloud drives the polling: it asks exactly one credentialed host per tailnet on a
slow cadence (service state changes when a human approves something), and that
answer covers every host on the tailnet. Agents never poll on their own, and each
agent enforces its own minimum interval of 60 seconds between control-plane
reads, re-serving its previous answer if asked sooner — your Tailscale API quota
is yours, and nothing on the Cloud side can spend more of it than that.

### Public Health

For a service with Funnel enabled, Cloud makes an ordinary HTTPS request to its
public Funnel address from the open internet and reports whether it answered.
That is the one check the agent cannot run for you: from inside the tailnet,
MagicDNS resolves a Funnel name to a tailnet address, so a request from this host
takes the tailnet path and always succeeds. Only an observer outside your tailnet
sees what a visitor sees.

The agent's part is to say *where* — it reports this node's MagicDNS name
alongside the Funnel port and path it configured, so Cloud requests exactly the
URL you published instead of guessing one. Nothing else is sent, no credential is
involved, and a service without Funnel enabled is never requested at all. HTTP
and HTTPS funnels are checked; a `tcp` or `tls-terminated-tcp` funnel is not,
because Tailscale's ingress accepts the connection itself and such a check would
report healthy even with the host gone.

Without credentials the agent still says so explicitly: its hello advertises that
it understands tailnet health but has no credentials for it, so Cloud reports "no
Tailscale credentials" and links to [Tailscale Admin
Setup](https://docktail.org/docs/tailscale-admin/#tailscale-admin-setup) rather than showing an outage —
or telling you to upgrade an agent that is already current. Local checks, Docker
events, metrics, and incidents are unaffected.

### Identity

Each host is identified by its Docker engine ID, used as a stable fingerprint.
A workspace key can enroll multiple hosts while its enrollment window is open
(one hour by default; the dashboard's agent key settings offer other lengths when a
key is created or its enrollment reopened). After the window closes, the key continues to authenticate
the hosts it already enrolled but cannot add another fingerprint until an
operator reopens enrollment in the Cloud dashboard. An agent waiting for a
reopened window retries automatically at a low rate.

The agent also reports its own Tailscale node ID and tailnet name when it has a
tailnet. The Services API calls the stable identity `nodeId`; it is the same
identity exposed as `Self.ID` by `tailscale status --json`. Cloud uses that exact
match to associate each service advertisement with its host. The tailnet name
groups the hosts that share a control plane, so Cloud knows which single host to
ask for tailnet health. Neither is required — without them the agent simply
reports fewer signals.

### Connection Problems

When Cloud refuses a connection, the agent logs the reason code and what to do
about it (`cloud: connection rejected. …` when it will retry,
`cloud: stopped reporting until this container restarts. …` when it will not).
The explanation repeats about every 30 minutes, so it stays near the end of
`docker logs`. DockTail itself keeps serving your services either way; only
reporting stops.

| Reason | Meaning | What the agent does | Fix |
| --- | --- | --- | --- |
| `http_401`, `invalid_key` | The workspace key was revoked, its workspace was deleted, or it is mistyped. | Stops. | Create a new agent key at [cloud.docktail.org/settings/agent-keys](https://cloud.docktail.org/settings/agent-keys), set it as `DOCKTAIL_CLOUD_KEY`, and recreate the container (`docker compose up -d`). |
| `blocked` | This host was blocked in the dashboard. | Checks again about every 15 minutes for up to 24 hours, then stops. | Unblock it at [cloud.docktail.org/hosts](https://cloud.docktail.org/hosts). After 24 hours, also restart the container. |
| `protocol_mismatch` | This DockTail image speaks a wire protocol Cloud no longer accepts. | Checks again about every 15 minutes for up to 24 hours, then stops. | Pull the latest DockTail image and recreate the container. |
| `http_403` | Something between the host and Cloud (a proxy, firewall, or WAF) refused the connection. | Checks again about every 15 minutes for up to 24 hours, then stops. | Allow outbound WebSocket connections to Cloud. After 24 hours, also restart the container. |
| `enrollment_closed` | The key's enrollment window closed before this host joined. | Retries every 30–60 seconds. | Reopen enrollment for the key at [cloud.docktail.org/settings/agent-keys](https://cloud.docktail.org/settings/agent-keys), or recreate the container with a new key. |
| `over_cap` | The workspace has no plan yet, or has reached its plan's host limit. | Retries every 30–60 seconds. | Choose a plan or upgrade it at [cloud.docktail.org/settings/billing](https://cloud.docktail.org/settings/billing), or remove an offline host. The agent reconnects on its own once there is room. |

A key cannot be changed while the container runs, so rotating keys always means
setting the new `DOCKTAIL_CLOUD_KEY` and recreating the container. Network errors
and temporary Cloud outages are not rejections: the agent reconnects on its own
with backoff.

### API And MCP Server

DockTail Cloud has a REST API and a remote MCP server, so an AI agent (Claude Code, Cursor, Codex, VS Code, Claude Desktop) or a script can read the same hosts, services, incidents, Docker events and captured logs as the dashboard, and find the root cause of an incident. Overview: [docktail.org/cloud/agents](https://docktail.org/cloud/agents/).

Both need a workspace with a plan or a running trial, and an API key that a person creates in Cloud:

1. Open the **MCP** page ([cloud.docktail.org/mcp](https://cloud.docktail.org/mcp)) or the **API** page ([cloud.docktail.org/api-access](https://cloud.docktail.org/api-access)) and choose **Create key**.
2. Pick a scope. `read` (the default) reaches every read endpoint and tool, which is enough to investigate any incident. `read_write` can also acknowledge and resolve incidents and start or stop maintenance windows.
3. Copy the key (`dtk_...`). It is shown once.

API keys (`dtk_...`) are separate from the workspace key (`dtc_...`) the DockTail agent uses; neither works in place of the other.

**MCP server**

- Endpoint: `https://cloud.docktail.org/api/mcp`, Streamable HTTP, stateless.
- Auth: `Authorization: Bearer dtk_...`.
- Claude Code: `claude mcp add --transport http docktail https://cloud.docktail.org/api/mcp --header "Authorization: Bearer dtk_..."`. The MCP page in Cloud shows the configuration for the other clients; Claude Desktop connects through the `mcp-remote` bridge.
- Read tools: `get_workspace`, `list_hosts`, `get_host`, `list_services`, `get_service`, `list_incidents`, `get_incident`, `get_incident_logs`, `list_events`, `list_maintenance_windows`.
- Write tools (`read_write` keys only): `acknowledge_incident`, `resolve_incident`, `start_maintenance`, `stop_maintenance`.
- Start with `get_workspace`. Use write tools only when the user asks for that change.

**REST API**

- Base URL: `https://cloud.docktail.org/api/v1`, same bearer key.
- OpenAPI 3.1 document: `https://cloud.docktail.org/api/v1/openapi.json` (no key needed).
- Reads: `GET /workspace`, `/hosts`, `/hosts/{id}`, `/services`, `/services/{id}`, `/incidents`, `/incidents/{id}`, `/incidents/{id}/logs`, `/events`, `/maintenance`.
- Writes (`read_write`): `POST /incidents/{id}/ack`, `/incidents/{id}/resolve`, `/maintenance/start`, `/maintenance/stop`.
- Responses are camelCase JSON, request bodies snake_case. Errors are `{"error": "<sentence>"}`.

```bash
curl -H "Authorization: Bearer $DOCKTAIL_API_KEY" \
  "https://cloud.docktail.org/api/v1/incidents?status=open"
```

API and MCP share one rate limit of 120 requests per key per minute. Keys are revoked on the same MCP and API pages; revoking one leaves the others working. Neither the API nor the MCP server can run anything on your hosts: they only read Cloud's data and, with `read_write`, change incident and maintenance state in Cloud. Writes are logged under the key's name in Settings → Activity.


## Reference

Use this section when checking exact configuration names, defaults, and supported protocols.

### Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
| `TAILSCALE_OAUTH_CLIENT_ID` | - | OAuth client ID. Enables automatic service creation when paired with the secret. |
| `TAILSCALE_OAUTH_CLIENT_SECRET` | - | OAuth client secret. Enables automatic service creation when paired with the client ID. |
| `TAILSCALE_API_KEY` | - | API key alternative to OAuth. |
| `TAILSCALE_TAILNET` | `-` | Tailnet ID. Defaults to the credential's tailnet. |
| `DEFAULT_SERVICE_TAGS` | `tag:container` | Default tags for services whose containers set no `docktail.tags` label. Tags are reconciled on every cycle; manual tag edits in the admin console are overwritten. |
| `IGNORE_SERVICE_NAMES` | - | Comma-separated service names DockTail must not drain, clear, delete, or restore missing advertisements for during reconciliation or shutdown cleanup. |
| `DELETE_UNUSED_SERVICES` | `false` | When `true`, DockTail deletes tailnet Service definitions that no host advertises anymore. Requires API credentials. See [Cleanup Behavior](https://docktail.org/docs/reference/#cleanup-behavior). |
| `SKIP_SHUTDOWN_CLEANUP` | `false` | When `true`, DockTail leaves its services and Funnels advertised on shutdown instead of draining and clearing them. This can keep ports exposed on the tailnet beyond what your current labels define; see [Cleanup Behavior](https://docktail.org/docs/reference/#cleanup-behavior). |
| `LOG_LEVEL` | `info` | Logging level for all output, including the DockTail Cloud module: `debug`, `info`, `warn`, or `error`. Any other value means `info`. |
| `RECONCILE_INTERVAL` | `60s` | State reconciliation interval. |
| `DOCKER_HOST` | `unix:///var/run/docker.sock` | Docker daemon socket. Rootless Docker typically uses `unix:///run/user/<uid>/docker.sock`. |
| `TAILSCALE_SOCKET` | `/var/run/tailscale/tailscaled.sock` | The `tailscaled` socket DockTail checks: the startup missing-socket hint, the [socket-loss check](https://docktail.org/docs/reference/#tailscale-socket-loss), and the image's health check. DockTail does not pass it to the bundled `tailscale` CLI, which does the serve and Funnel work at its own default of `/var/run/tailscale/tailscaled.sock`, so mount the daemon's socket directory at `/var/run/tailscale` either way. |
| `EXIT_ON_SOCKET_LOSS` | `true` | When `true`, DockTail exits if the Tailscale socket stays unreachable past the grace period, so the container's restart policy can re-establish the mount. See [Tailscale Socket Loss](https://docktail.org/docs/reference/#tailscale-socket-loss). |
| `SOCKET_LOSS_GRACE_PERIOD` | `90s` | How long the Tailscale socket may stay unreachable before DockTail exits. Must be longer than a normal `tailscaled` restart. |
| `UPDATE_CHECK` | `true` | When `true`, DockTail checks once a day whether a newer release exists and logs it once. Set `false` to never contact GitHub. See [Version And Updates](https://docktail.org/docs/reference/#version-and-updates). |
| `HEALTH_FILE` | `/tmp/docktail-health.json` | Where DockTail writes the status file that `docktail health` (the image's health check) reads. Point it at a writable path if the container's `/tmp` is read-only. See [Health Check](https://docktail.org/docs/reference/#health-check). |

If both OAuth and API key credentials are configured, DockTail uses OAuth.

Sensitive credential variables can also be loaded from files. This is useful with Docker secrets, Swarm secrets, and other secret mounts. Direct environment variables take precedence; when the direct variable is unset, DockTail checks `FILE__VARIABLE_NAME` first and `VARIABLE_NAME_FILE` second. The file content is used as the value with trailing newlines removed.

Supported file-backed credential variables:

| Direct variable | File variable alternatives |
| --- | --- |
| `TAILSCALE_OAUTH_CLIENT_ID` | `FILE__TAILSCALE_OAUTH_CLIENT_ID`, `TAILSCALE_OAUTH_CLIENT_ID_FILE` |
| `TAILSCALE_OAUTH_CLIENT_SECRET` | `FILE__TAILSCALE_OAUTH_CLIENT_SECRET`, `TAILSCALE_OAUTH_CLIENT_SECRET_FILE` |
| `TAILSCALE_API_KEY` | `FILE__TAILSCALE_API_KEY`, `TAILSCALE_API_KEY_FILE` |

`IGNORE_SERVICE_NAMES` accepts bare names like `grafana` and fully qualified names like `svc:grafana`.

Durations (`RECONCILE_INTERVAL`, `SOCKET_LOSS_GRACE_PERIOD`) use Go syntax such as `30s`, `5m` or `1h30m`; booleans accept `true`/`false`, `1`/`0`, and `t`/`f`. An unparseable value in one of the variables above logs a warning and falls back to the default.

#### Docker Connection And Log Output

DockTail builds its Docker client from the standard Docker environment variables, so they work as they do for the `docker` CLI. Besides `DOCKER_HOST` above, which also takes `tcp://host:port` (for example a [read-only socket proxy](https://docktail.org/docs/security/#read-only-socket-proxy)):

| Variable | Default | Description |
| --- | --- | --- |
| `DOCKER_API_VERSION` | negotiated | Pins the Docker API version instead of negotiating it with the daemon. |
| `DOCKER_CERT_PATH` | - | Directory with `ca.pem`, `cert.pem` and `key.pem`. Setting it makes DockTail talk TLS to a `tcp://` daemon. |
| `DOCKER_TLS_VERIFY` | - | Used with `DOCKER_CERT_PATH`: any non-empty value verifies the daemon's certificate; unset or empty skips verification. |

Log lines are colored only when stdout is a terminal; setting `NO_COLOR` (to any value) or `TERM=dumb` turns color off there too.

`TAILSCALE_AUTH_KEY` in the examples is read by the `tailscale/tailscale` sidecar container (as `TS_AUTHKEY`), not by DockTail.

#### DockTail Cloud (optional)

These variables enable optional DockTail Cloud reporting. They are opt-in: the agent is completely inert unless `DOCKTAIL_CLOUD_KEY` is set. See [DockTail Cloud](https://docktail.org/docs/cloud/).

| Variable | Default | Description |
| --- | --- | --- |
| `DOCKTAIL_CLOUD_KEY` | - | Workspace key (`dtc_...`) from the cloud dashboard. Enables reporting. Inert when unset. |
| `DOCKTAIL_LOG_LEVEL` | `info` | Read, but currently has no effect: the cloud module logs at the level `LOG_LEVEL` sets. |
| `DOCKTAIL_CHECK_INTERVAL` | `30s` | How often local-vantage checks run (5s–5m). A value outside that range, or one that does not parse, keeps the cloud module from starting; DockTail itself keeps running. |
| `DOCKTAIL_HOST_ROOT` | `/host` | Where the host's root filesystem is bind-mounted, for whole-host disk usage. Only used when that path exists; see [Disk Usage](https://docktail.org/docs/cloud/#disk-usage). |

Local-development overrides: `DOCKTAIL_CLOUD_URL` replaces the built-in ingest
endpoint. `ws://` is allowed for loopback endpoints; non-loopback plaintext
requires `DOCKTAIL_CLOUD_ALLOW_INSECURE=true` and must never be used in
production. Non-loopback production endpoints must use `wss://`.

### Supported Protocols

Tailscale-facing `docktail.service.service-protocol` values:

| Value | Description |
| --- | --- |
| `http` | Layer 7 HTTP. |
| `https` | Layer 7 HTTPS with automatic TLS. |
| `tcp` | Layer 4 TCP. |
| `tls-terminated-tcp` | Layer 4 TCP; Tailscale terminates incoming TLS and forwards decrypted TCP to the backend. |

`docktail.service.path` selects the HTTP(S) Serve mount point and defaults to `/`. It must start with `/` and is rejected for TCP protocols.

`docktail.service.proxy-protocol` (`1` or `2`) is valid only with `tcp` or `tls-terminated-tcp`. It is off by default because the backend must understand the PROXY header. HTTP/HTTPS values are rejected.

Container-facing `docktail.service.protocol` values:

| Value | Description |
| --- | --- |
| `http` | HTTP backend. |
| `https` | HTTPS backend with a valid certificate. |
| `https+insecure` | HTTPS backend with a self-signed certificate. |
| `tcp` | TCP backend. |
| `tls-terminated-tcp` | TCP backend with TLS termination. |

Funnel `docktail.funnel.protocol` values:

| Value | Description |
| --- | --- |
| `http` | HTTP Funnel. |
| `https` | HTTPS Funnel. |
| `tcp` | TCP Funnel. |
| `tls-terminated-tcp` | TLS-terminated TCP Funnel. |

`docktail.funnel.path` is supported only with HTTP(S) Funnel protocols. It defaults to `/` and must start with `/`.

### Cleanup Behavior

DockTail attempts to clean up the services and Funnels it advertises locally when it shuts down, reducing stale exposure while it is not running. Service cleanup runs serially, once per service name even when it has several ports: drain first, then clear. Draining stops new connections; DockTail clears the configuration immediately afterward without waiting for all existing connections to finish.

Cleanup has an 8-second budget, leaving headroom within Docker’s default 10-second stop timeout. Cleanup stops scheduling commands when its budget expires. A crash, SIGKILL, daemon error, or the cleanup deadline can leave some services configured or advertised; reconciliation repairs missing advertisements when DockTail resumes.

On startup and every reconciliation cycle, DockTail also reads `tailscale debug prefs`. If a desired service has matching Serve configuration but is missing from `AdvertiseServices`, DockTail restores its advertisement with `tailscale serve advertise` after syncing its control-plane definition (when API sync is enabled). This repairs services left drained but configured after interrupted cleanup without rewriting their endpoints. It uses the same local daemon socket as Serve, requires no additional API credentials, and runs once per service name. Ignored services and service names with endpoint conflicts are excluded from this repair. Failed, malformed, or unsupported prefs reads are treated as unknown state: DockTail skips advertisement repair for that cycle while continuing normal configuration reconciliation.

A manual `tailscale serve drain` of a desired, matching service is therefore reversed on the next successful reconciliation. Stop the backing container, remove its service labels, or exclude the service from advertisement repair with `IGNORE_SERVICE_NAMES` if the drain should persist. Local configuration and advertisement do not guarantee that Tailscale has propagated peer routes or that the service is reachable.

`SKIP_SHUTDOWN_CLEANUP=true` disables this cleanup. DockTail then leaves its services and Funnels advertised when it exits instead of tearing them down. It affects only graceful shutdown; a hard crash never runs cleanup either way.

> **Warning:** Enabling this keeps ports exposed on the tailnet while DockTail is down, potentially beyond what your current labels define. The serve and Funnel configuration lives in `tailscaled`, not in DockTail, so anything DockTail last advertised keeps serving on the host until DockTail comes back. If you stop a container, remove it, or delete its DockTail labels while DockTail is not running, that service (and any Funnel) stays reachable for the entire downtime and is only reconciled away once DockTail restarts. Only enable `SKIP_SHUTDOWN_CLEANUP` if keeping services reachable across DockTail restarts is worth deliberately skipping cleanup, and treat the advertised surface as detached from your labels until DockTail is running again.

On restart, DockTail re-adopts the still-advertised services and removes only those whose containers are no longer running. Ignored services (`IGNORE_SERVICE_NAMES`) are never cleaned up regardless of this setting.

By default DockTail does **not** delete Tailscale Service definitions from the Control Plane when containers stop; this is a conservative strategy that avoids removing definitions unexpectedly.

#### Deleting unused Service definitions

Set `DELETE_UNUSED_SERVICES=true` to let DockTail remove Service definitions that are no longer advertised by any host. This requires API credentials (OAuth or API key). It is disabled by default.

During each reconciliation, for every Service definition in the tailnet DockTail:

1. Keeps the Service if DockTail currently advertises it (it is backed by a running container).
2. Keeps the Service if its name is listed in `IGNORE_SERVICE_NAMES`.
3. Asks the Control Plane which hosts are registered for the Service. If **at least one** host is registered, DockTail keeps it.
4. Deletes the Service only when **no** host is registered for it.

Because the decision is based on the tailnet-wide host list, this is safe to enable on multiple DockTail instances at once: a Service hosted by any other host or instance always reports at least one host and is never deleted. DockTail also skips deletion whenever an API call fails, so it never deletes under uncertainty.

> **Note:** That host list is a configuration and approval registry, not a liveness signal. A host stays listed while it is configured to host the Service, and remains listed for some time after it stops advertising it. Cleanup can therefore lag behind reality — it may keep a definition longer than expected, but it will not delete one that is still in use.

This cleanup runs only during reconciliation, not during shutdown, so restarting DockTail does not delete and recreate the Services of still-running containers.

> **Note:** When enabled, DockTail may also delete Service definitions it did not create if they have no advertising hosts (for example, a Service you defined in the admin console but never advertised). Add such names to `IGNORE_SERVICE_NAMES` to protect them.

### Tailscale Socket Loss

DockTail talks to `tailscaled` over a Unix socket that it bind-mounts from the
host or shares with a sidecar. That mount is resolved once, when the container
starts.

This matters whenever `tailscaled` restarts. On a host install under systemd, the
unit declares `RuntimeDirectory=tailscale` and leaves `RuntimeDirectoryPreserve`
at its default of `no`, so systemd **removes `/run/tailscale` when the daemon
stops and creates a new directory when it starts**. A container that mounted the
old directory stays attached to it after it is unlinked, and the new socket never
becomes visible inside the container. Sharing the socket through a host path with
a sidecar that gets recreated has the same effect. Retrying cannot help: the
socket is not late, it is in a directory this container can no longer see.

An upgrade is the most common trigger, because upgrading the package restarts the
daemon — but it is not the only one. Measured on Debian 12 (systemd 252,
tailscale 1.102.2), an ordinary `systemctl restart tailscaled` replaces the
directory just as an upgrade does, and so does any stop/start pair:

| | directory | DockTail's mount |
| --- | --- | --- |
| before | inode 264, socket present | inode 264, socket present |
| after `systemctl restart tailscaled` | inode 412, socket present | inode 264, empty |
| after the container restarts | inode 412, socket present | inode 412, socket present |

Because of this, mounting the directory rather than the socket file — which is
what the setup guide recommends, and which does survive the socket file being
recreated — is not on its own enough to survive a daemon restart on a
systemd host.

Without intervention DockTail would keep running in that state — process alive,
every Tailscale call failing, and every Service it manages drifting until it goes
offline, with no recovery until someone restarts the container by hand.

So DockTail probes the socket, and if it stays unreachable for
`SOCKET_LOSS_GRACE_PERIOD` (default `90s`) it logs the reason and exits, letting
the container's restart policy re-create the container and with it the mount.

- **Use a restart policy.** `restart: unless-stopped` (or `always`) is what turns
  the exit into a recovery. Without one, DockTail stops instead of restarting.
- The grace period must stay comfortably longer than a normal `tailscaled`
  restart, which takes a second or two. Brief outages are ignored and never
  cause an exit.
- The check arms only after the socket has been reachable at least once, so
  starting DockTail before `tailscaled` waits rather than exits. At startup
  DockTail also waits up to 15 seconds for the socket before its first
  reconcile, so a sidecar that is still starting does not delay your Services
  by a whole `RECONCILE_INTERVAL`.
- Set `EXIT_ON_SOCKET_LOSS=false` to disable it and keep the old behaviour of
  retrying forever.

Prefer a named volume over a host path when you run `tailscaled` as a sidecar: a
volume keeps one directory for its lifetime, so recreating the sidecar cannot
detach DockTail's mount in the first place.

### Version And Updates

DockTail logs its version on startup (`Starting DockTail version=…`), and the
binary prints it on request:

```bash
docker exec docktail /app/docktail --version
# or, without a running container:
docker run --rm ghcr.io/marvinvr/docktail:latest --version
```

Include that version in bug reports.

About 30 seconds after startup and then once a day (hourly after a failed
check), a release build asks the
GitHub API for the repository's tags and, when a newer stable release exists,
logs it once:

```text
INF A newer DockTail release is available; pull the new image and recreate the container to update (set UPDATE_CHECK=false to stop checking) current=1.8.2 latest=1.8.3 release_notes=https://github.com/marvinvr/docktail/releases
```

The request is an anonymous `GET` to `api.github.com` that carries nothing
about your installation beyond the `docktail/<version>` user agent (GitHub
sees the source IP, as with any request). It is
skipped for development builds, a failure is only logged at debug level, and
`UPDATE_CHECK=false` turns it off. Pre-release tags are never offered, and a
pre-release build newer than the latest stable release is not nagged.

### Health Check

The image's `HEALTHCHECK` runs `docktail health`, which tracks DockTail itself
rather than only the Tailscale daemon. The running process rewrites a small
JSON status file every 10 seconds (and after every reconcile) at `HEALTH_FILE`;
`docktail health` reads it, prints a one-line verdict, and exits `0` when
healthy and `1` when not. Nothing listens on a port.

DockTail is **unhealthy** when:

- the status file is missing or has not been updated for a minute (DockTail is
  hung, stopped, or cannot write the file);
- the `tailscaled` socket does not accept connections;
- the last two reconciles could not read the containers from Docker;
- no reconcile has finished for three reconcile intervals (at least three
  minutes), meaning the loop is stuck.

A reconcile that fails for individual services — a label conflict, a service
the tailnet refuses — is reported as `healthy, with errors`: that is one
container's configuration, and DockTail keeps serving the rest.

The [DockTail Cloud](https://docktail.org/docs/cloud/#docktail-cloud) link state (`connecting`,
`connected`, `disconnected`, `rejected`, or `failed`) is included in the output
but never makes the container unhealthy: a cloud outage or a revoked key does
not stop DockTail from serving containers, and a restart triggered by the
health status (Swarm, autoheal) would drain every service without fixing it.

```bash
docker exec docktail /app/docktail health
# healthy: last reconcile 12s ago; cloud connected for 3h12m4s

docker inspect --format '{{json .State.Health}}' docktail   # Docker's view, with recent outputs
docker exec docktail cat /tmp/docktail-health.json          # the full status
```

With a read-only root filesystem, mount a `tmpfs` at `/tmp` or set
`HEALTH_FILE` to a writable path; otherwise DockTail logs a warning and the
health check reports unhealthy.

### Useful Links

- Tailscale Services documentation: `https://tailscale.com/kb/1552/tailscale-services`
- Tailscale Funnel documentation: `https://tailscale.com/kb/1311/tailscale-funnel`
- Tailscale service configuration reference: `https://tailscale.com/kb/1589/tailscale-services-configuration-file`
- Docker SDK for Go: `https://docs.docker.com/engine/api/sdk/`


## How It Works

DockTail is a reconciliation loop between Docker and Tailscale.

```text
Docker container labels
        |
        v
DockTail watches Docker events
        |
        v
DockTail parses service and Funnel config
        |
        v
DockTail resolves the backend IP and port
        |
        v
Tailscale CLI advertises services and Funnels
        |
        v
Tailnet clients access container services
```

### Reconciliation Flow

1. DockTail monitors Docker events for container starts and stops.
2. It extracts service configuration from container labels. If several containers claim the same service name and port, that endpoint is frozen in its current state and an error is logged; see [Service Name Conflicts Between Containers](https://docktail.org/docs/labels/#service-name-conflicts-between-containers).
3. It resolves the backend destination from Docker network settings or published ports.
4. It generates Tailscale service configuration pointing to that backend.
5. If OAuth or API key credentials are configured, it creates service definitions through the Tailscale API and keeps their tags and descriptions in sync with the labels; manual edits to either are overwritten. This runs before any new service is advertised, matching Tailscale's documented order: define the Service first, then advertise a host for it.
6. It executes the Tailscale CLI to advertise services and Funnels.
7. If `DELETE_UNUSED_SERVICES` is enabled, it deletes tailnet service definitions that no host is registered for anymore.
8. It periodically reconciles state so container IP changes are handled automatically. It also compares matching desired services with the local `AdvertiseServices` preferences and restores missing advertisements, including services left drained after interrupted cleanup; see [Cleanup Behavior](https://docktail.org/docs/reference/#cleanup-behavior).

### Networking Model

Direct mode is the default. DockTail reaches containers through their Docker network IPs, so application containers do not need published host ports.

When `docktail.service.direct=false`, DockTail uses Docker published port bindings instead. In that mode, the target port must be published to the host. This is also the reliable path when host `tailscaled` cannot reach container IPs, which is common with [rootless Docker](https://docktail.org/docs/installation/#rootless-docker).

TCP forwards hide the tailnet client address by default: the backend sees tailscaled. Set `docktail.service.proxy-protocol` to `1` or `2` so Tailscale prepends a PROXY protocol header. The backend must accept that header; HTTP/HTTPS services cannot use it.

Containers using `network_mode: host` are served on `127.0.0.1` (IPv4, to avoid dual-stack `localhost`→`::1` refusals). The local health check probes them from wherever the agent runs: directly via `127.0.0.1` when the agent shares the host's network namespace, or via the agent's docker-network gateway (the host's bridge address) when the agent runs in its own container. Containers using `network_mode: none` cannot use direct mode.


## How-To Guides

Each guide takes one real setup from start to finish. They assume DockTail already runs on the Docker host and the Tailscale side is set up; if not, start with the [Quick Start](https://docktail.org/docs/quick-start/) and [Tailscale Admin Setup](https://docktail.org/docs/tailscale-admin/).

- [Expose Jellyfin over Tailscale](https://docktail.org/docs/guides/jellyfin-over-tailscale/): stream your media library to every device on your tailnet over HTTPS, without opening a port.
- [Expose Home Assistant over Tailscale](https://docktail.org/docs/guides/home-assistant-over-tailscale/): reach Home Assistant and the companion app from anywhere, including the `trusted_proxies` setting it needs.
- [Migrate from TSDProxy to DockTail](https://docktail.org/docs/guides/migrate-from-tsdproxy/): translate `tsdproxy.*` labels to `docktail.*` labels and switch over one app at a time.

For single-label recipes (databases over TCP, SSH, PROXY protocol, public Funnel), see [Examples](https://docktail.org/docs/examples/).


## Expose Jellyfin Over Tailscale

This guide puts [Jellyfin](https://jellyfin.org) on your tailnet as its own Tailscale Service, at `https://jellyfin.your-tailnet.ts.net`. Every device signed in to your tailnet can stream from it, nothing is published on your router, and Jellyfin does not need a Docker port mapping.

### Before You Start

- DockTail runs on the Docker host, as in the [Quick Start](https://docktail.org/docs/quick-start/).
- The host is tagged and allowed to advertise services; see [ACL Configuration](https://docktail.org/docs/tailscale-admin/#acl-configuration).
- DockTail has [OAuth credentials](https://docktail.org/docs/tailscale-admin/#oauth-credentials), so it creates the `jellyfin` service definition itself. Without them, create the service in the Tailscale admin console first.
- HTTPS is enabled for your tailnet (Tailscale admin console, DNS page), so Tailscale can issue the certificate.

### The Compose File

```yaml
services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    restart: unless-stopped
    volumes:
      - ./config:/config
      - ./cache:/cache
      - /path/to/media:/media:ro
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=jellyfin"
      - "docktail.service.port=8096"
      - "docktail.service.service-port=443"
```

What the labels do:

- `docktail.service.port=8096` is Jellyfin's HTTP port inside the container. DockTail proxies straight to the container IP, so there is no `ports:` section.
- `docktail.service.service-port=443` makes the tailnet side HTTPS with an automatic certificate. The backend stays plain HTTP, because the backend protocol only defaults to HTTPS when the container port is `443`.

Start it:

```bash
docker compose up -d
```

The first time, the service may need approval in the Services tab of the Tailscale admin console; see [Approve Services](https://docktail.org/docs/tailscale-admin/#approve-services). Then open `https://jellyfin.your-tailnet.ts.net` and run the Jellyfin setup wizard.

### Jellyfin Apps

In the Jellyfin apps (Android, iOS, Android TV, Swiftfin, Jellyfin Media Player), add the server as `https://jellyfin.your-tailnet.ts.net`. The device needs Tailscale running. Tailscale Serve passes WebSocket upgrades through, which Jellyfin uses for remote control and live updates.

### Client IPs In Jellyfin

Tailscale Serve sends the tailnet client's address in `X-Forwarded-For`. Jellyfin ignores that header unless the request comes from a known proxy, so by default its dashboard and logs show the address `tailscaled` connects from: with Tailscale on the host, the gateway of the Docker network Jellyfin is on.

To see real client addresses, look up that gateway and add it under **Dashboard > Networking > Known proxies**, then restart Jellyfin:

```bash
docker network inspect <project>_default --format '{{range .IPAM.Config}}{{.Gateway}}{{end}}'
```

This is optional. Streaming works either way.

### Host Networking For DLNA

Jellyfin's documentation says host networking is required for DLNA. DockTail works with it: a container with `network_mode: host` is served on `127.0.0.1`, so the same labels apply.

```yaml
services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    restart: unless-stopped
    network_mode: host
    volumes:
      - ./config:/config
      - ./cache:/cache
      - /path/to/media:/media:ro
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=jellyfin"
      - "docktail.service.port=8096"
      - "docktail.service.service-port=443"
```

With host networking, Jellyfin also listens on port 8096 of every host interface, so it stays reachable on your LAN as before. In that case the known proxy to add is `127.0.0.1`.

### Optional: Share Publicly With Funnel

To let someone without Tailscale reach Jellyfin, add a [Funnel](https://docktail.org/docs/labels/#funnel-labels). The host needs the `funnel` node attribute first; see [Funnel ACL](https://docktail.org/docs/tailscale-admin/#funnel-acl).

```yaml
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=jellyfin"
      - "docktail.service.port=8096"
      - "docktail.service.service-port=443"
      - "docktail.funnel.enable=true"
      - "docktail.funnel.port=8096"
```

The public URL is the machine's name, `https://your-machine.your-tailnet.ts.net`, not `jellyfin.your-tailnet.ts.net`. Anyone on the internet then reaches the Jellyfin login page, so use strong passwords and keep Jellyfin updated.

### Troubleshooting

- **The service never shows up.** `docker compose logs docktail` names the cause, most often an untagged host or a missing auto-approver.
- **It shows up but does not connect.** On rootless Docker the host often cannot reach container IPs; see [Rootless Docker](https://docktail.org/docs/installation/#rootless-docker).
- **Jellyfin is on a network DockTail does not pick.** If the container is attached to several networks, name the one to use with `docktail.service.network`; see [Service Labels](https://docktail.org/docs/labels/#service-labels).


## Expose Home Assistant Over Tailscale

This guide puts a Home Assistant container on your tailnet as a Tailscale Service, at `https://homeassistant.your-tailnet.ts.net`, for the browser and the companion app. It covers the one setting Home Assistant needs behind any reverse proxy, which is what Tailscale Serve is.

### Before You Start

- DockTail runs on the Docker host, as in the [Quick Start](https://docktail.org/docs/quick-start/).
- The host is tagged and allowed to advertise services; see [ACL Configuration](https://docktail.org/docs/tailscale-admin/#acl-configuration).
- DockTail has [OAuth credentials](https://docktail.org/docs/tailscale-admin/#oauth-credentials), so it creates the `homeassistant` service definition itself.
- HTTPS is enabled for your tailnet (Tailscale admin console, DNS page).

### The Compose File

This is Home Assistant's own Compose example for a container install, with the DockTail labels added:

```yaml
services:
  homeassistant:
    image: ghcr.io/home-assistant/home-assistant:stable
    container_name: homeassistant
    restart: unless-stopped
    stop_grace_period: 60s
    privileged: true
    network_mode: host
    volumes:
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    environment:
      - TZ=Europe/Zurich
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=homeassistant"
      - "docktail.service.port=8123"
      - "docktail.service.service-port=443"
```

Home Assistant runs with `network_mode: host`, as its installation guide shows, so device discovery on your LAN keeps working. DockTail serves host-network containers on `127.0.0.1`, so the service points at `127.0.0.1:8123`. `service-port=443` makes the tailnet side HTTPS with an automatic certificate; Home Assistant itself stays on plain HTTP.

### Trust The Proxy

Tailscale Serve adds an `X-Forwarded-For` header with the tailnet client's address. Home Assistant rejects such requests unless it is told to trust the proxy: the page answers **400: Bad Request**, and the Home Assistant log says:

```text
A request from a reverse proxy was received from 127.0.0.1, but your HTTP integration is not set-up for reverse proxies
```

Add this to `configuration.yaml`, then restart Home Assistant:

```yaml
http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1
```

The two keys go together; Home Assistant refuses one without the other. Newer releases also offer the same settings in the UI as **Trust X-Forwarded-For** and **Trusted proxies**.

`127.0.0.1` is right for the setup above, where Home Assistant uses host networking. If you run it on a Docker bridge network instead, `tailscaled` connects from that network's gateway, and the log line names that address. Put the address, or its network such as `172.16.0.0/12`, in `trusted_proxies`. If the log says `Received X-Forwarded-For header from an untrusted proxy`, the address in `trusted_proxies` does not match.

### Start And Approve

```bash
docker compose up -d
```

The first time, the service may need approval in the Services tab of the Tailscale admin console; see [Approve Services](https://docktail.org/docs/tailscale-admin/#approve-services). Then open `https://homeassistant.your-tailnet.ts.net`.

### Companion App

In the Home Assistant companion app, use `https://homeassistant.your-tailnet.ts.net` as the server address, on a phone that runs Tailscale. Tailscale Serve passes WebSocket upgrades through, which the frontend and the app rely on. If you set Home Assistant's own URLs (Settings, System, Network), use the same address so links and notifications point at the tailnet name.

### On The LAN

Nothing changes on your local network: with host networking, Home Assistant still listens on port 8123 of the host, so `http://<host-ip>:8123` keeps working next to the tailnet address.

### Troubleshooting

- **400: Bad Request.** The proxy is not trusted yet; see [Trust The Proxy](https://docktail.org/docs/guides/home-assistant-over-tailscale/#trust-the-proxy).
- **The service never shows up.** `docker compose logs docktail` names the cause, most often an untagged host or a missing auto-approver.
- **It works in the browser but the app cannot connect.** Check that the phone is connected to Tailscale and that the server address uses `https://` without a port.


## Migrate From TSDProxy To DockTail

[TSDProxy](https://github.com/almeidapaulopt/tsdproxy) and DockTail both put Docker containers on a tailnet from labels. They differ in how. TSDProxy v2 gives each proxied container its own Tailscale machine (an embedded `tsnet` node), so every app is a separate device in your admin console. DockTail runs next to the host's Tailscale and publishes each app as a [Tailscale Service](https://tailscale.com/kb/1552/tailscale-services) of that one host, so apps do not take device slots and each keeps a stable `https://<name>.your-tailnet.ts.net` address.

This guide maps TSDProxy v2 labels (checked against v2.3.4) to DockTail labels and walks through a switch, one container at a time.

### Is DockTail The Right Move?

Stay on TSDProxy, at least for some apps, if you rely on something DockTail does not do:

- TSDProxy's web dashboard, health checks, webhooks or Prometheus metrics. DockTail has no UI of its own; monitoring is the separate, paid [DockTail Cloud](https://docktail.org/docs/cloud/).
- UDP or port ranges. DockTail serves HTTP, HTTPS, TCP and TLS-terminated TCP.
- No Tailscale on the host. DockTail needs a tagged `tailscaled`, either on the host or as a [sidecar container](https://docktail.org/docs/installation/#tailscale-sidecar).
- Per-device features for each app, such as its own machine in the admin console.

The two can share a host while you move: TSDProxy only reads `tsdproxy.*` labels and DockTail only reads `docktail.*` labels. See the [DockTail vs TSDProxy](https://docktail.org/vs/tsdproxy/) comparison for the full picture.

### Step 1: Set Up The Tailscale Side

TSDProxy logs each node in with an auth key, an OAuth client or by hand from its dashboard. DockTail instead needs:

1. The Docker host (or a Tailscale sidecar) on your tailnet with a tag such as `tag:server`.
2. An ACL with `tag:server` and `tag:container` in `tagOwners` and an `autoApprovers.services` rule; see [ACL Configuration](https://docktail.org/docs/tailscale-admin/#acl-configuration).
3. An OAuth client, so DockTail creates the service definitions; see [OAuth Credentials](https://docktail.org/docs/tailscale-admin/#oauth-credentials).
4. For any app you had on Funnel, the `funnel` node attribute for `tag:server`; see [Funnel ACL](https://docktail.org/docs/tailscale-admin/#funnel-acl).

### Step 2: Run DockTail

Add DockTail as in the [Quick Start](https://docktail.org/docs/quick-start/), or the [sidecar setup](https://docktail.org/docs/installation/#tailscale-sidecar) if the host does not run Tailscale. Leave TSDProxy running for now.

### Step 3: Translate The Labels

A typical TSDProxy v2 container:

```yaml
services:
  myapp:
    image: nginx:latest
    labels:
      - "tsdproxy.enable=true"
      - "tsdproxy.name=myapp"
      - "tsdproxy.port.1=443/https:80/http"
```

The same app with DockTail:

```yaml
services:
  myapp:
    image: nginx:latest
    labels:
      - "docktail.service.enable=true"
      - "docktail.service.name=myapp"
      - "docktail.service.port=80"
      - "docktail.service.service-port=443"
```

`service-port=443` makes the tailnet side HTTPS with an automatic certificate, and the backend stays HTTP. Neither tool needs a `ports:` section: DockTail proxies straight to the container IP.

Label by label:

| TSDProxy v2 | DockTail |
| --- | --- |
| `tsdproxy.enable=true` | `docktail.service.enable=true` |
| `tsdproxy.name=myapp` (defaults to the container name) | `docktail.service.name=myapp` (required) |
| `tsdproxy.port.1=443/https:80/http` | `docktail.service.port=80` and `docktail.service.service-port=443` |
| `tsdproxy.port.1=80/http:80/http` | `docktail.service.port=80` (HTTP on port 80 is the default) |
| `tsdproxy.port.2=22/tcp:2222/tcp` | `docktail.service.1.name=myapp`, `docktail.service.1.port=2222`, `docktail.service.1.protocol=tcp`, `docktail.service.1.service-port=22` |
| `no_tlsvalidate` port option, for a backend with a self-signed certificate | `docktail.service.protocol=https+insecure` |
| `tailscale_funnel` port option | `docktail.funnel.enable=true` and `docktail.funnel.port=<container port>` |
| `tsdproxy.tags` | `docktail.tags` (needs API credentials) |
| `tsdproxy.autodetect` | Not needed: DockTail uses the container IP on its Docker network; `docktail.service.network` picks the network |
| `tsdproxy.container_port`, `tsdproxy.scheme`, `tsdproxy.funnel` (deprecated v1 labels) | `docktail.service.port`, `docktail.service.protocol`, `docktail.funnel.enable` |
| `tsdproxy.ephemeral`, `tsdproxy.authkey`, `tsdproxy.authkeyfile`, `tsdproxy.runwebclient`, `tsdproxy.tsnet_verbose` | No equivalent: there is no per-app Tailscale node to configure |
| `tsdproxy.dash.*`, `tsdproxy.health_check_*` | No equivalent in DockTail itself; [DockTail Cloud labels](https://docktail.org/docs/labels/#docktail-cloud-labels) cover checks if you use Cloud |

Extra ports become numbered services of the same container; see [Multiple Services From One Container](https://docktail.org/docs/labels/#multiple-services-from-one-container). Using the same `name` on a different `service-port` puts both ports on one address, like the SSH example in [Examples](https://docktail.org/docs/examples/#https-with-tcp-ssh).

Two behaviours change:

- **Funnel URLs.** With TSDProxy a Funnel answers on the app's own machine name. With DockTail it answers on the DockTail host's machine name, `https://your-machine.your-tailnet.ts.net`, because Funnel runs on that node. Several apps can share it through different `docktail.funnel.path` values or Funnel ports `443`, `8443` and `10000`; see [Funnel Labels](https://docktail.org/docs/labels/#funnel-labels).
- **Access rules.** ACL rules that name the old TSDProxy machines, by hostname or by tag, do not apply to Services. Write the rules for the services instead, by their tags (`tag:container` by default); see Tailscale's [Services documentation](https://tailscale.com/kb/1552/tailscale-services).

### Step 4: Switch One App

For each app:

1. Replace its `tsdproxy.*` labels with the `docktail.*` labels from Step 3.
2. In the Tailscale admin console, remove the app's old TSDProxy machine, so the old device no longer holds the name you want for the service.
3. Recreate the container: `docker compose up -d myapp`.
4. Approve the service in the Services tab if your ACL does not auto-approve it; see [Approve Services](https://docktail.org/docs/tailscale-admin/#approve-services).
5. Open `https://myapp.your-tailnet.ts.net` and check it.

When the last app has moved, stop TSDProxy and delete its data volume.

### Troubleshooting

- **`service hosts must be tagged nodes` in the DockTail logs.** The host or sidecar is not tagged; see [Tailscale On Host](https://docktail.org/docs/installation/#tailscale-on-host).
- **The service advertises but does not connect.** On rootless Docker the host often cannot reach container IPs; see [Rootless Docker](https://docktail.org/docs/installation/#rootless-docker).
- **`Service endpoint conflict` in the logs.** Two containers claim the same service name and port, for example after copying labels. DockTail leaves that endpoint as it is until only one claims it; see [Service Name Conflicts Between Containers](https://docktail.org/docs/labels/#service-name-conflicts-between-containers).
