Laravel
Reverb
Laravel Reverb with Docker
Run Laravel Reverb by passing the Artisan command as the container's command. Reverb is Laravel's WebSocket server for real-time communication.
Want to skip the setup? Spin Pro handles Laravel Reverb on your VPS with Docker and zero-downtime deployments—all configured for you.
Before using Reverb with Docker, follow the Laravel Reverb setup instructions to install and configure the Reverb package in your Laravel application.
Docker Compose example
This example runs Reverb as a separate container using the same image as your web service. Reverb requires a reverse proxy (like Traefik) to route WebSocket traffic correctly.
Key points:
- Use the same image for both your web and Reverb services
- Reverb runs on a different port than your web server (8000 vs 8080)
- Set
SIGTERMas the stop signal for graceful shutdown (especially forfpm-apacheandfpm-nginx) - Include a health check to monitor Reverb status
- Configure a reverse proxy to route traffic to the correct container
compose.yml
services:
php:
image: my/laravel-app
labels:
- "traefik.enable=true"
- "traefik.http.routers.laravel.tls=true"
- "traefik.http.routers.laravel.entrypoints=websecure"
- "traefik.http.routers.laravel.rule=Host(`https://app.example.com`)"
- "traefik.http.services.laravel.loadbalancer.server.port=8080"
- "traefik.http.services.laravel.loadbalancer.server.scheme=http"
reverb:
image: my/laravel-app
command: ["php", "/var/www/html/artisan", "reverb:start", "--port=8000"]
stop_signal: SIGTERM
healthcheck:
test: ["CMD", "healthcheck-reverb"]
start_period: 10s
labels:
- "traefik.enable=true"
- "traefik.http.routers.reverb.tls=true"
- "traefik.http.routers.reverb.entrypoints=websecure"
- "traefik.http.routers.reverb.rule=Host(`https://reverb.example.com`)"
- "traefik.http.services.reverb.loadbalancer.server.port=8000"
- "traefik.http.services.reverb.loadbalancer.server.scheme=http"
Environment variable configuration
Don't confuse CLIENT variables with SERVER variables. The
REVERB_SERVER_* variables configure the Reverb daemon itself, while REVERB_* variables tell your frontend clients how to connect.Configure these environment variables in your Laravel application:
| Laravel ENV Variable | Description | Value (matching example above) |
|---|---|---|
REVERB_HOST | The hostname the CLIENT will connect to | reverb.example.com |
REVERB_PORT | The port the CLIENT will connect to | 443 |
REVERB_SCHEME | The scheme the CLIENT will connect to | https |
Advanced configuration
Multiple processes in one container: If you're running
fpm-nginx or fpm-apache and you'd like to have everything in a single container, you can write your own S6 Overlay service script to properly manage multiple processes in a single container. Learn more about about this in our Using S6 Overlay guide.