Laravel
Queue
Laravel Queue with Docker
All you need to do is pass the Laravel Queue command to the container and Laravel will start the queue worker.
php artisan queue:work --tries=3
Important concepts
Want to skip the setup? Spin Pro handles Laravel schedulers on your VPS with Docker and zero-downtime deployments—all configured for you.
- It's usually best to run the queue as a separate container (but using the same image)
- If you're using
fpm-apacheorfpm-nginx, might need to set the stop signal toSIGTERMfor a graceful shutdown (see this PR for more details why) - Be sure to set the health check
- Notice we're using the same
my/laravel-appimage for both the PHP and Queue services. This is a common practice to keep the image consistent. - If you need to run the queue in the same container, you might want to look into writing your own S6 Overlay script to manage and monitor multiple processes in one container.
Run it with Docker
Notice we're calling the artisan command explicitly with the full path (
/var/www/html/artisan). This is because we need to run the command from the context of the container.Example & Simplified Docker Compose File
compose.yml
services:
php:
image: my/laravel-app
queue:
image: my/laravel-app
command: ["php", "/var/www/html/artisan", "queue:work", "--tries=3"]
stop_signal: SIGTERM # Graceful shutdown for fpm-apache or fpm-nginx
healthcheck:
# This is our native healthcheck script for the queue
test: ["CMD", "healthcheck-queue"]
start_period: 10s