Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tailscale-dev/ScaleTail/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Tailscale containers in ScaleTail are configured through environment variables. This reference documents all available variables, their types, defaults, and usage.All environment variables prefixed with
TS_ are Tailscale-specific and control the behavior of the Tailscale sidecar container.Core Variables
These variables are required for basic Tailscale functionality.TS_AUTHKEY
Authentication key for joining your Tailscale network (Tailnet)
.env
- Use reusable keys for multiple service deployments
- Enable pre-approved to skip manual device authorization
- Set appropriate expiration periods (90 days is common)
- Use tagged keys to automatically apply ACL rules
TS_STATE_DIR
Directory where Tailscale stores state information
Always mount this directory to a host volume. Without persistence, your container will create a new Tailscale identity on every restart.
tailscaled.state- Connection state and machine identity- Private keys and certificates
- Local configuration
Serve and Funnel Configuration
TS_SERVE_CONFIG
Path to the serve.json configuration file for Tailscale Serve/Funnel
serve.json
- TCP
- Web
- AllowFunnel
- Jellyfin:
8096 - Portainer:
9000 - Vaultwarden:
80 - Home Assistant:
8123 - Plex:
32400
TS_CERT_DOMAIN
Domain name for TLS certificate (used in serve.json template)
.env
The
${TS_CERT_DOMAIN} syntax is Docker Compose variable substitution, not a Tailscale feature. The $$ escapes the $ so Docker Compose doesn’t try to substitute it.Network Configuration
TS_USERSPACE
Run Tailscale in userspace networking mode
true: Userspace networking (default) - More portable, works without elevated privilegesfalse: Kernel networking - Better performance, requirescap_add: net_adminand/dev/net/tun
false
Why? ScaleTail uses kernel networking for better performance and full feature support.
Required for Kernel Mode (TS_USERSPACE=false):
TS_ACCEPT_DNS
Accept DNS configuration from Tailscale (MagicDNS)
- You have MagicDNS enabled in your Tailnet
- Your application needs to resolve Tailscale hostnames
- You want automatic DNS for other Tailnet devices
Enable MagicDNS in your Tailnet at https://login.tailscale.com/admin/dns
TS_EXTRA_ARGS
Additional command-line arguments to pass to tailscaled
- Exit Node
- Subnet Router
- Custom Hostname
- Multiple Flags
Authentication and Security
TS_AUTH_ONCE
Only authenticate on first run, reuse existing state on subsequent runs
- Prevents consuming auth key usage limits on restarts
- Maintains stable machine identity
- Recommended for production deployments
true
Health and Monitoring
TS_ENABLE_HEALTH_CHECK
Enable the built-in HTTP health check endpoint
/healthz that returns the Tailscale connection status.
Usage:
true
Why? Health checks ensure the application container only starts after Tailscale has successfully connected.
Docker Health Check:
- 200 OK: Tailscale connected and operational
- 503 Service Unavailable: Tailscale not connected or starting up
TS_LOCAL_ADDR_PORT
Address and port for the local API and health check endpoint
<address>:<port>
127.0.0.1:41234- Only localhost (recommended):41234- All interfaces0.0.0.0:41234- All interfaces (explicit)
127.0.0.1:41234
The port must not conflict with your application’s port. The default 41234 is chosen to avoid common application ports.
Complete Example
Here’s a complete example showing all commonly used environment variables:Environment Variable Reference Table
| Variable | Type | Required | Default | Description |
|---|---|---|---|---|
TS_AUTHKEY | string | Yes | - | Authentication key for Tailnet |
TS_STATE_DIR | string | No | /var/lib/tailscale | State persistence directory |
TS_SERVE_CONFIG | string | No | - | Path to serve.json configuration |
TS_USERSPACE | boolean | No | true | Use userspace networking |
TS_ACCEPT_DNS | boolean | No | false | Accept MagicDNS configuration |
TS_EXTRA_ARGS | string | No | - | Additional tailscaled arguments |
TS_AUTH_ONCE | boolean | No | false | Only authenticate on first run |
TS_ENABLE_HEALTH_CHECK | boolean | No | false | Enable health check endpoint |
TS_LOCAL_ADDR_PORT | string | No | :41112 | Health check endpoint address |
Service-Specific Variables
These are not Tailscale variables but are commonly used in ScaleTail configurations:SERVICE
Name of the service being deployed
.env
IMAGE_URL
Docker image for the application container
.env
DNS_SERVER
Custom DNS server for the Tailscale container
.env
Exit Node Example
For deploying a Tailscale exit node, use this configuration:compose.yaml
Exit nodes require
sysctls for IP forwarding and typically use network_mode: bridge instead of sharing with an application container.Troubleshooting
TS_AUTHKEY not working
TS_AUTHKEY not working
Symptoms: Container fails to join Tailnet, logs show auth errorsSolutions:
- Verify the key is correct and complete
- Check if the key has expired
- Ensure the key hasn’t reached its usage limit (for non-reusable keys)
- Try generating a new key
State not persisting
State not persisting
Symptoms: New machine appears in Tailnet on every restartSolutions:
- Verify
TS_STATE_DIRvolume is correctly mounted - Check directory permissions (should be writable by container)
- Ensure
TS_AUTH_ONCE=trueis set - Check if the volume path exists on host
Health check failing
Health check failing
Symptoms: Container shows unhealthy, application doesn’t startSolutions:
- Verify
TS_ENABLE_HEALTH_CHECK=trueis set - Check
TS_LOCAL_ADDR_PORTmatches health check URL - Ensure port is not in use by application
- Review Tailscale logs for connection issues
- Test manually:
docker exec tailscale-service wget -O- http://127.0.0.1:41234/healthz
DNS not resolving
DNS not resolving
Symptoms: Can’t resolve Tailscale hostnames from containerSolutions:
- Enable
TS_ACCEPT_DNS=true - Verify MagicDNS is enabled in Tailnet settings
- Check DNS configuration in Tailscale admin console
- Test resolution:
docker exec app-service nslookup other-device.tailnet.ts.net
Kernel mode not working
Kernel mode not working
Symptoms: Container fails with network errors when
TS_USERSPACE=falseSolutions:- Verify
/dev/net/tunexists:ls -l /dev/net/tun - Ensure
cap_add: - net_adminis present - Check container has necessary permissions
- Try userspace mode as fallback:
TS_USERSPACE=true
Best Practices
Use .env Files
Store all variables in
.env files and add them to .gitignore to prevent committing secrets.Enable Health Checks
Always use
TS_ENABLE_HEALTH_CHECK=true to ensure reliable startup ordering with application containers.Persist State
Always mount
TS_STATE_DIR to a volume to maintain stable machine identity across restarts.Use TS_AUTH_ONCE
Set
TS_AUTH_ONCE=true in production to avoid consuming auth key limits on restarts.Kernel Mode Performance
Use
TS_USERSPACE=false with proper capabilities for better performance in production.Document Overrides
Comment why you’re using non-default values, especially for
TS_EXTRA_ARGS.Next Steps
Tailscale Setup
Generate auth keys and configure your Tailnet
Sidecar Pattern
Understand how these variables work in the sidecar architecture
Serve vs Funnel
Learn how TS_SERVE_CONFIG controls access
Deploy Services
Put these variables into practice