[{"data":1,"prerenderedAt":476},["Reactive",2],{"content-query-218G7OIKDv":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"head":10,"layout":12,"body":13,"_type":471,"_id":472,"_source":473,"_file":474,"_extension":475},"/docs/laravel/laravel-queue","laravel",false,"","Laravel Queue with Docker","Learn how to configure a Laravel Queue with Docker.",{"title":11},"Laravel Queue with Docker - Docker PHP - Server Side Up","docs",{"type":14,"children":15,"toc":466},"root",[16,24,30,75,82,163,169,186,431,460],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"laravel-queue-with-docker",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":23,"value":29},"All you need to do is pass the Laravel Queue command to the container and Laravel will start the queue worker.",{"type":17,"tag":31,"props":32,"children":34},"code-panel",{"label":33},"Usual Laravel Queue Command",[35],{"type":17,"tag":36,"props":37,"children":41},"pre",{"className":38,"code":39,"language":40,"meta":7,"style":7},"language-sh shiki shiki-themes github-dark github-dark monokai","php artisan queue:work --tries=3\n","sh",[42],{"type":17,"tag":43,"props":44,"children":45},"code",{"__ignoreMap":7},[46],{"type":17,"tag":47,"props":48,"children":51},"span",{"class":49,"line":50},"line",1,[52,58,64,69],{"type":17,"tag":47,"props":53,"children":55},{"style":54},"--shiki-default:#B392F0;--shiki-dark:#B392F0;--shiki-sepia:#A6E22E",[56],{"type":23,"value":57},"php",{"type":17,"tag":47,"props":59,"children":61},{"style":60},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF;--shiki-sepia:#E6DB74",[62],{"type":23,"value":63}," artisan",{"type":17,"tag":47,"props":65,"children":66},{"style":60},[67],{"type":23,"value":68}," queue:work",{"type":17,"tag":47,"props":70,"children":72},{"style":71},"--shiki-default:#79B8FF;--shiki-dark:#79B8FF;--shiki-sepia:#AE81FF",[73],{"type":23,"value":74}," --tries=3\n",{"type":17,"tag":76,"props":77,"children":79},"h2",{"id":78},"important-concepts",[80],{"type":23,"value":81},"Important concepts",{"type":17,"tag":83,"props":84,"children":85},"ol",{},[86,92,132,137,150],{"type":17,"tag":87,"props":88,"children":89},"li",{},[90],{"type":23,"value":91},"It's usually best to run the queue as a separate container (but using the same image)",{"type":17,"tag":87,"props":93,"children":94},{},[95,97,103,105,111,113,119,121,130],{"type":23,"value":96},"If you're using ",{"type":17,"tag":43,"props":98,"children":100},{"className":99},[],[101],{"type":23,"value":102},"fpm-apache",{"type":23,"value":104}," or ",{"type":17,"tag":43,"props":106,"children":108},{"className":107},[],[109],{"type":23,"value":110},"fpm-nginx",{"type":23,"value":112},", might need to set the stop signal to ",{"type":17,"tag":43,"props":114,"children":116},{"className":115},[],[117],{"type":23,"value":118},"SIGTERM",{"type":23,"value":120}," for a graceful shutdown (see this ",{"type":17,"tag":122,"props":123,"children":127},"a",{"href":124,"rel":125},"https://github.com/serversideup/docker-php/pull/437",[126],"nofollow",[128],{"type":23,"value":129},"PR",{"type":23,"value":131}," for more details why)",{"type":17,"tag":87,"props":133,"children":134},{},[135],{"type":23,"value":136},"Be sure to set the health check",{"type":17,"tag":87,"props":138,"children":139},{},[140,142,148],{"type":23,"value":141},"Notice we're using the same ",{"type":17,"tag":43,"props":143,"children":145},{"className":144},[],[146],{"type":23,"value":147},"my/laravel-app",{"type":23,"value":149}," image for both the PHP and Queue services. This is a common practice to keep the image consistent.",{"type":17,"tag":87,"props":151,"children":152},{},[153,155,161],{"type":23,"value":154},"If you need to run the queue in the same container, you might want to look into ",{"type":17,"tag":122,"props":156,"children":158},{"href":157},"/docs/guide/using-s6-overlay#customizing-the-initialization-process",[159],{"type":23,"value":160},"writing your own S6 Overlay script",{"type":23,"value":162}," to manage and monitor multiple processes in one container.",{"type":17,"tag":76,"props":164,"children":166},{"id":165},"run-it-with-docker",[167],{"type":23,"value":168},"Run it with Docker",{"type":17,"tag":170,"props":171,"children":172},"note",{},[173],{"type":17,"tag":25,"props":174,"children":175},{},[176,178,184],{"type":23,"value":177},"Notice we're calling the artisan command explicitly with the full path (",{"type":17,"tag":43,"props":179,"children":181},{"className":180},[],[182],{"type":23,"value":183},"/var/www/html/artisan",{"type":23,"value":185},"). This is because we need to run the command from the context of the container.",{"type":17,"tag":31,"props":187,"children":189},{"label":188},"Example & Simplified Docker Compose File",[190],{"type":17,"tag":36,"props":191,"children":195},{"className":192,"code":193,"language":194,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-dark monokai","services:\n  php:\n    image: my/laravel-app\n\n  queue:\n    image: my/laravel-app\n    command: [\"php\", \"/var/www/html/artisan\", \"queue:work\", \"--tries=3\"]\n    stop_signal: SIGTERM # Set this for graceful shutdown if you're using fpm-apache or fpm-nginx\n    healthcheck:\n      # This is our native healthcheck script for the queue\n      test: [\"CMD\", \"healthcheck-queue\"]\n      start_period: 10s\n","yaml",[196],{"type":17,"tag":43,"props":197,"children":198},{"__ignoreMap":7},[199,214,227,246,256,269,285,337,360,373,382,413],{"type":17,"tag":47,"props":200,"children":201},{"class":49,"line":50},[202,208],{"type":17,"tag":47,"props":203,"children":205},{"style":204},"--shiki-default:#85E89D;--shiki-dark:#85E89D;--shiki-sepia:#F92672",[206],{"type":23,"value":207},"services",{"type":17,"tag":47,"props":209,"children":211},{"style":210},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8;--shiki-sepia:#F8F8F2",[212],{"type":23,"value":213},":\n",{"type":17,"tag":47,"props":215,"children":217},{"class":49,"line":216},2,[218,223],{"type":17,"tag":47,"props":219,"children":220},{"style":204},[221],{"type":23,"value":222},"  php",{"type":17,"tag":47,"props":224,"children":225},{"style":210},[226],{"type":23,"value":213},{"type":17,"tag":47,"props":228,"children":230},{"class":49,"line":229},3,[231,236,241],{"type":17,"tag":47,"props":232,"children":233},{"style":204},[234],{"type":23,"value":235},"    image",{"type":17,"tag":47,"props":237,"children":238},{"style":210},[239],{"type":23,"value":240},": ",{"type":17,"tag":47,"props":242,"children":243},{"style":60},[244],{"type":23,"value":245},"my/laravel-app\n",{"type":17,"tag":47,"props":247,"children":249},{"class":49,"line":248},4,[250],{"type":17,"tag":47,"props":251,"children":253},{"emptyLinePlaceholder":252},true,[254],{"type":23,"value":255},"\n",{"type":17,"tag":47,"props":257,"children":259},{"class":49,"line":258},5,[260,265],{"type":17,"tag":47,"props":261,"children":262},{"style":204},[263],{"type":23,"value":264},"  queue",{"type":17,"tag":47,"props":266,"children":267},{"style":210},[268],{"type":23,"value":213},{"type":17,"tag":47,"props":270,"children":272},{"class":49,"line":271},6,[273,277,281],{"type":17,"tag":47,"props":274,"children":275},{"style":204},[276],{"type":23,"value":235},{"type":17,"tag":47,"props":278,"children":279},{"style":210},[280],{"type":23,"value":240},{"type":17,"tag":47,"props":282,"children":283},{"style":60},[284],{"type":23,"value":245},{"type":17,"tag":47,"props":286,"children":288},{"class":49,"line":287},7,[289,294,299,304,309,314,318,323,327,332],{"type":17,"tag":47,"props":290,"children":291},{"style":204},[292],{"type":23,"value":293},"    command",{"type":17,"tag":47,"props":295,"children":296},{"style":210},[297],{"type":23,"value":298},": [",{"type":17,"tag":47,"props":300,"children":301},{"style":60},[302],{"type":23,"value":303},"\"php\"",{"type":17,"tag":47,"props":305,"children":306},{"style":210},[307],{"type":23,"value":308},", ",{"type":17,"tag":47,"props":310,"children":311},{"style":60},[312],{"type":23,"value":313},"\"/var/www/html/artisan\"",{"type":17,"tag":47,"props":315,"children":316},{"style":210},[317],{"type":23,"value":308},{"type":17,"tag":47,"props":319,"children":320},{"style":60},[321],{"type":23,"value":322},"\"queue:work\"",{"type":17,"tag":47,"props":324,"children":325},{"style":210},[326],{"type":23,"value":308},{"type":17,"tag":47,"props":328,"children":329},{"style":60},[330],{"type":23,"value":331},"\"--tries=3\"",{"type":17,"tag":47,"props":333,"children":334},{"style":210},[335],{"type":23,"value":336},"]\n",{"type":17,"tag":47,"props":338,"children":340},{"class":49,"line":339},8,[341,346,350,354],{"type":17,"tag":47,"props":342,"children":343},{"style":204},[344],{"type":23,"value":345},"    stop_signal",{"type":17,"tag":47,"props":347,"children":348},{"style":210},[349],{"type":23,"value":240},{"type":17,"tag":47,"props":351,"children":352},{"style":60},[353],{"type":23,"value":118},{"type":17,"tag":47,"props":355,"children":357},{"style":356},"--shiki-default:#6A737D;--shiki-dark:#6A737D;--shiki-sepia:#88846F",[358],{"type":23,"value":359}," # Set this for graceful shutdown if you're using fpm-apache or fpm-nginx\n",{"type":17,"tag":47,"props":361,"children":363},{"class":49,"line":362},9,[364,369],{"type":17,"tag":47,"props":365,"children":366},{"style":204},[367],{"type":23,"value":368},"    healthcheck",{"type":17,"tag":47,"props":370,"children":371},{"style":210},[372],{"type":23,"value":213},{"type":17,"tag":47,"props":374,"children":376},{"class":49,"line":375},10,[377],{"type":17,"tag":47,"props":378,"children":379},{"style":356},[380],{"type":23,"value":381},"      # This is our native healthcheck script for the queue\n",{"type":17,"tag":47,"props":383,"children":385},{"class":49,"line":384},11,[386,391,395,400,404,409],{"type":17,"tag":47,"props":387,"children":388},{"style":204},[389],{"type":23,"value":390},"      test",{"type":17,"tag":47,"props":392,"children":393},{"style":210},[394],{"type":23,"value":298},{"type":17,"tag":47,"props":396,"children":397},{"style":60},[398],{"type":23,"value":399},"\"CMD\"",{"type":17,"tag":47,"props":401,"children":402},{"style":210},[403],{"type":23,"value":308},{"type":17,"tag":47,"props":405,"children":406},{"style":60},[407],{"type":23,"value":408},"\"healthcheck-queue\"",{"type":17,"tag":47,"props":410,"children":411},{"style":210},[412],{"type":23,"value":336},{"type":17,"tag":47,"props":414,"children":416},{"class":49,"line":415},12,[417,422,426],{"type":17,"tag":47,"props":418,"children":419},{"style":204},[420],{"type":23,"value":421},"      start_period",{"type":17,"tag":47,"props":423,"children":424},{"style":210},[425],{"type":23,"value":240},{"type":17,"tag":47,"props":427,"children":428},{"style":60},[429],{"type":23,"value":430},"10s\n",{"type":17,"tag":170,"props":432,"children":433},{},[434,439,445,450],{"type":17,"tag":25,"props":435,"children":436},{},[437],{"type":23,"value":438},"Notice we're disabling the healthcheck",{"type":17,"tag":76,"props":440,"children":442},{"id":441},"get-up-and-running-the-easy-way",[443],{"type":23,"value":444},"Get Up and Running The Easy Way",{"type":17,"tag":25,"props":446,"children":447},{},[448],{"type":23,"value":449},"We do all the heavy lifting for you with Spin Pro. It's as easy as selecting it in a menu and we'll configure everything else for you. Learn how easy it is to get up and running with Queues on Spin Pro.",{"type":17,"tag":25,"props":451,"children":452},{},[453],{"type":17,"tag":122,"props":454,"children":457},{"href":455,"rel":456},"https://getspin.pro/docs/services/laravel-queues",[126],[458],{"type":23,"value":459},"Learn more about Laravel Queues + Spin Pro →",{"type":17,"tag":461,"props":462,"children":463},"style",{},[464],{"type":23,"value":465},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}",{"title":7,"searchDepth":216,"depth":216,"links":467},[468,469,470],{"id":78,"depth":216,"text":81},{"id":165,"depth":216,"text":168},{"id":441,"depth":216,"text":444},"markdown","content:docs:4.laravel:3.laravel-queue.md","content","docs/4.laravel/3.laravel-queue.md","md",1727889428263]