Docker Laravel Redis - 队列初始化问题

Docker Laravel Redis - Queue initialization problem

Docker 好吧。我编辑了文件中的 laravel 和 redis 容器。两个容器都工作正常。但是当我不 运行 artisan queue:work 从外部发出命令时,队列不会启动。我不知道如何解决这种情况。另外,我对supervisiord文件做了必要的设置,它在laravel sail notes

我是 Docker 的初学者。对不起,如果这是一个错误或错误的问题。

Docker Yml

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./docker/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        container_name: LaravelTest
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-8000}:8000'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
    mysql:
        image: 'mysql:8.0'
        container_name: MySql
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_USER: '${DB_USERNAME}'
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - "/var/lib/mysql"
        networks:
            - sail
    phpmyadmin:
        image: 'phpmyadmin:latest'
        container_name: PhpMyAdmin
        ports:
            - 8081:80
        environment:
            PMA_HOST: mysql
            MYSQL_ROOT_USER: '${DB_USERNAME}'
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
        depends_on:
            - mysql
        networks:
            - sail
    redis:
        image: 'redis:alpine'
        container_name: Redis
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
        healthcheck:
            test: ["CMD", "redis-cli", "ping"]
            retries: 3
            timeout: 5s
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local

您始终需要运行 artisan queue:work 命令。但是在生产模式下,它不是那样工作的。正如 Laravel 的文档中提到的 here, You need to use a process monitor such as Supervisor 以确保队列工作人员始终 运行s 在后台并且不会停止 运行ning.