Laravel

Queue

Laravel Queue with Docker

Run Laravel queue workers by passing the Artisan queue command as the container's command. This allows you to scale queue workers independently from your web server.

Docker Compose example

Want to skip the setup? Spin Pro handles Laravel queue workers on your VPS with Docker and zero-downtime deployments—all configured for you.

This example runs a dedicated queue container using the same image as your web service. Use the full path to Artisan (/var/www/html/artisan) when defining the container command.

Key points:

  • Use the same image for both your web and queue services
  • Set SIGTERM as the stop signal for graceful shutdown (especially for fpm-apache and fpm-nginx)
  • Include a health check to monitor queue worker status
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
    healthcheck:
      # This is our native healthcheck script for the queue
      test: ["CMD", "healthcheck-queue"]
      start_period: 10s

Advanced configuration

Graceful shutdown: The SIGTERM signal ensures queue workers finish 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.