I am looking to setup Redis in my local dev environment, I am using DDEV in Laravel Projects.
I've followed the steps here to add redis to the project: 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
.
Please would somebody be able to help with the correctly setting this up for a laravel project?
Just for reference I am on a MacbookAir 2021 BigSur M1 Chipset.
UPDATE 2023: Use github.com/drud/ddev-redis and ensure your redis server connection is set to redis
in config. I just had to change redis host in database.php
connection 127.0.0.1
to redis
in a laravel 4.2 project to work locally.
===================================
To get this working locally:
I updated the docker-compose.redis.yaml
to the following:
# 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:
REDIS_HOST=redis
Now the Redis container remains available:
Can now trigger and process correctly via:
ddev artisan queue:work redis --queue=mycustomqueue