Laravel
Horizon
Laravel Horizon with Docker
Run Laravel Horizon by passing the Artisan command as the container's command. Horizon provides a dashboard and monitoring for your Redis queues.
Docker Compose example
Want to skip the setup? Spin Pro handles Laravel Horizon on your VPS with Docker and zero-downtime deployments—all configured for you.
This example runs a dedicated Horizon container using the same image as your web service. Horizon requires Redis to be running and properly configured in your .env file.
Key points:
- Use the same image for both your web and Horizon services
- Ensure Redis is running before starting Horizon
- Configure Redis connection details in your
.envfile - Set
SIGTERMas the stop signal for graceful shutdown (especially forfpm-apacheandfpm-nginx) - Include a health check to monitor Horizon status
compose.yml
services:
php:
image: my/laravel-app
redis:
image: redis:6
command: "redis-server --appendonly yes --requirepass redispassword"
horizon:
image: my/laravel-app
command: ["php", "/var/www/html/artisan", "horizon"]
stop_signal: SIGTERM
healthcheck:
test: ["CMD", "healthcheck-horizon"]
start_period: 10s
Advanced configuration
Graceful shutdown: The SIGTERM signal ensures Horizon finishes processing current jobs before stopping. This is especially important for fpm-apache and fpm-nginx images.
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.