Docker and laravel’s Question on redis

  docker, question

Run the laravel framework in the docker environment and use the predis extension. Error reporting when linking redis:
图片描述

At last, docker’s system environment variable covered laravel’s. env variable.
There are two solutions

  1. Add the following code under docker-compose.yml file
environment:
 REDIS_PORT: 6379

I tried this method but it didn’t work. I don’t know why. I’m trying to explain it here.

  1. Directly modify. env configuration fileREDIS_HOST=dnmp_redis_1:6379, this method is effective

Finally, put a reference linkLink description