What is a Tailscale Sidecar?
A sidecar is a companion container that runs alongside your main application container. In ScaleTail configurations:- Tailscale container: Handles all networking, authentication, and encryption
- Application container: Runs your service (Jellyfin, Plex, Nextcloud, etc.)
- Network sharing: The application routes all traffic through Tailscale’s network stack
The sidecar pattern means you can add Tailscale to any existing Docker service without modifying the application image or code.
The network_mode: service Pattern
Thenetwork_mode: service:tailscale directive is the core of the sidecar configuration. Here’s what it does:
How It Works
When you setnetwork_mode: service:tailscale, Docker:
- Shares the network namespace: The application container uses the exact same network stack as the Tailscale container
- Routes all traffic: Every network request from the application goes through Tailscale
- Provides localhost access: The application can bind to
127.0.0.1and Tailscale can proxy it
Key Implications
No Direct Port Exposure
The application container cannot expose ports directly. All traffic must go through Tailscale, ensuring security.
Shared Network Identity
Both containers share the same IP address and hostname within your Tailnet.
Localhost Communication
Tailscale proxies requests to
127.0.0.1:<port> where your application listens.Container Isolation
Processes remain isolated - only the network namespace is shared.
Example Flow
- Your device connects to
jellyfin.tail-scale.ts.net:443 - Tailscale container receives the request
- Tailscale proxies to
http://127.0.0.1:8096(Jellyfin’s listening port) - Jellyfin processes and responds
- Tailscale encrypts and sends back to your device
Understanding Tailnets
A Tailnet is your private Tailscale network - think of it as a secure VPN that connects all your devices.Tailnet Characteristics
- Unique namespace: Each Tailnet has a unique name like
tail1234.ts.net - Device hostnames: Devices appear as
hostname.tail1234.ts.net - Private by default: Only devices in your Tailnet can communicate
- Encrypted mesh: Direct, encrypted connections between devices (when possible)
Your Services on a Tailnet
When you deploy a ScaleTail service:- You want personal access to your services
- You’re sharing with family/team on the same Tailnet
- Security and privacy are priorities
- You don’t need public internet access
- End-to-end encryption
- No public exposure
- No additional authentication needed
- Built-in HTTPS with Tailscale certificates
Tailscale Funnel (Public Access)
Funnel exposes your service to the public internet through Tailscale’s infrastructure.- You need to share with people outside your Tailnet
- You’re hosting a public website or API
- You want public access without port forwarding
- You need a public HTTPS endpoint
- No router configuration or port forwarding
- Automatic HTTPS certificates
- DDoS protection from Tailscale
- Can disable anytime
Comparison Table
| Feature | Serve (Private) | Funnel (Public) |
|---|---|---|
| Access | Tailnet devices only | Anyone on the internet |
| Authentication | Tailscale membership | Application-level required |
| Use Case | Personal services, internal tools | Public websites, shared resources |
| Security | Maximum (encrypted, private) | Depends on application |
| Configuration | "AllowFunnel": false | "AllowFunnel": true |
Health Checks and Dependencies
ScaleTail configurations use Docker health checks to ensure services start in the correct order and remain operational.Tailscale Health Check
The Tailscale container includes a built-in health check:- Tailscale daemon is running
- Connected to your Tailnet
- Has a valid Tailnet IP address
- Network interface is operational
Application Dependency
The application waits for Tailscale to be healthy before starting:- Prevents application from starting before networking is ready
- Ensures reliable service initialization
- Allows Docker to restart unhealthy containers automatically
The
start_period gives the application time to initialize before health checks begin. Adjust this if your application takes longer to start.Environment Variables Overview
ScaleTail configurations use environment variables for flexible deployment. Here are the essential ones:Tailscale Variables
Application Variables
Using .env Files
Store these in a.env file in the same directory as your compose.yaml:
.env