简体   繁体   English

如何正确设置 REDIS 与 DDEV / Z469A31FD9D773110F14057BAECCDD25Z 用于 Laravel 本地?

[英]How to correctly setup REDIS with DDEV / DOCKER for Laravel local?

I am looking to setup Redis in my local dev environment, I am using DDEV in Laravel Projects.我希望在我的本地开发环境中设置 Redis,我在 Laravel 项目中使用 DDEV。

I've followed the steps here to add redis to the project: https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/redis我已按照此处的步骤将 redis 添加到项目中: https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/redis

After a ddev restart I can see Redis is getting pulled into the container however it instantly falls over which you can see from running a docker ps -a .ddev restart后,我可以看到 Redis 被拉入容器中,但是它立即跌倒,您可以通过运行docker ps -a看到这一点。

在此处输入图像描述

Please would somebody be able to help with the correctly setting this up for a laravel project?请有人能够帮助正确设置 laravel 项目吗?

Just for reference I am on a MacbookAir 2021 BigSur M1 Chipset.仅供参考,我使用的是 MacbookAir 2021 BigSur M1 芯片组。

To get this working locally:要使其在本地工作:

I updated the docker-compose.redis.yaml to the following:我将docker-compose.redis.yaml更新为以下内容:

# ddev redis recipe file
#
version: "3.6"

services:
  redis:
    container_name: ddev-${DDEV_SITENAME}-redis
    image: redis:latest
    ports:
      - 6379
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      - ".:/mnt/ddev_config"
      - "./redis:/usr/local/etc/redis"
    command: ["redis-server", "--bind", "redis", "--port", "6379"]
  web:
    depends_on:
      - redis
    links:
      - redis:redis

Actual changes to file:文件的实际更改:

image: redis:latest
command: ["redis-server", "--bind", "redis", "--port", "6379"]

And in the projects .env file set:在项目.env文件集中:

REDIS_HOST=redis

Now the Redis container remains available:现在 Redis 容器仍然可用: 在此处输入图像描述

Can now trigger and process correctly via:现在可以通过以下方式正确触发和处理:

ddev artisan queue:work redis --queue=mycustomqueue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM