Laravel Queue with Docker

All you need to do is pass the Laravel Queue command to the container and S6 will automatically monitor it for you.

Important concepts

  1. It's usually best to run the queue as a separate container (but using the same image)
  2. If you need to run the queue in the same container, you might want to look into extending the image with S6 Overlay and have S6 monitor the process for you

Task Command

php artisan queue:work --tries=3

Example Docker Compose File

version: '3'
    image: my/laravel-app
      PHP_FPM_POOL_NAME: "my-app_php"

    image: my/laravel-app
    # Switch to "webuser" before running `php artisan`
    # Declare command in list manner for environment variable expansion
    command: ["su", "webuser", "-c", "php artisan queue:work --tries=3"]
      PHP_FPM_POOL_NAME: "my-app_queue"