1

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.

enter image description here

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.

1 Answer 1

3

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: enter image description here

Can now trigger and process correctly via:

ddev artisan queue:work redis --queue=mycustomqueue
Sign up to request clarification or add additional context in comments.

6 Comments

If the recipe in github.com/drud/ddev-contrib/tree/master/… is incorrect, could you please make a PR there? It worked OK last I tried it. But it's not oriented at Laravel, so maybe that's the issue? Looks to me like the biggest issue might have just been the REDIS_HOST=redis in your .env.
Thanks for the reply rfay, I've double checked on this and if I return the command line to: command: ["redis-server", "/usr/local/etc/redis/redis.conf"] Then this results in the redis container immediately falling over upon a ddev restart even though REDIS_HOST=redis is set in the .env. Changing the command line to: command: ["redis-server", "--bind", "redis", "--port", "6379"] This allows redis to spin up successfully for me. I've created a branch for this in the project however do not have to permission to push a branch and then create a pull request?
If you're asking how to create a PR in ddev-contrib... Like most open-source projects, you create a fork, then a branch in the fork, then create a PR.
Cheers, this is my first open-source forking so appreciate the guidance. I've created a PR for this now.
These days, the official add-on would be better, github.com/drud/ddev-redis ddev get drud/ddev-redis
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.