Solution to the problem that docker redis cannot connect: 1. Pull the redis container; 2. Download and obtain the configuration file redis.conf from github; 3. Check the IP assigned by docker to the container; 4. Use the configuration file Just run redis.
The operating environment of this article: Windows 7 system, redis version 4.0.9, Dell G3 computer.
How to solve the problem that docker redis cannot connect?
The application deployed to the docker container cannot connect to the redis container
##Each container run by docker is isolated. Redis does not allow external connections by default. Therefore, if you want to connect the application deployed in the docker container to redis, you need to modify the default configuration of redis. Here we can run redis with the configuration file. Pull the redis containerdocker pull redis
docker pull redis:4.0.9
Download the redis release version, and select the version that matches the one in the container.
Get redis.conf, comment bind:127.0.0.1
Turn off protected mode
Run with configuration file
docker run -p 6379:6379 --name myredis -v /usr/local/docker/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf --appendonly yes
docker exec -it myredis /bin/bash
cat /etc/hosts
docker usage tutorial"
The above is the detailed content of How to solve the problem that docker redis cannot connect. For more information, please follow other related articles on the PHP Chinese website!