Redis Could not connect to Redis at 127.0.0.1 under docker 6379

after I downloaded the redis, configuration in docker, I used the redis-cli command to report an error Could not connect to Redis at 127.0.0.1 Could not connect to Redis at 6379

< H2 > using docker, for the first time, the following steps are all done in the book, and I don"t know what went wrong. < / H2 >

1. Download redis

sudo docker pull redis:latest

2. Start redis image Container, and enable redis-server persistence service

sudo docker run --name redis-server -d redis redis-server --appendonly yes

3. Start Redis image Container as a client and connect to redis-server

sudo docker run --rm=true -it --link redis-server:redis redis /bin/bash

4. Then enter the bash inside Container

REDIS_PORT_6379_TCP_PROTO=tcp
REDIS_PORT=tcp://172.17.0.2:6379
REDIS_NAME=/stupefied_bhaskara/redis
HOSTNAME=24f9eeb3e8e6
REDIS_PORT_6379_TCP_ADDR=172.17.0.2
REDIS_DOWNLOAD_SHA=fc53e73ae7586bcdacb4b63875d1ff04f68c5474c1ddeda78f00e5ae2eed1bbb
REDIS_PORT_6379_TCP=tcp://172.17.0.2:6379
REDIS_VERSION=4.0.11
REDIS_ENV_REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-4.0.11.tar.gz
PWD=/data
HOME=/root
GOSU_VERSION=1.10
REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-4.0.11.tar.gz
REDIS_PORT_6379_TCP_PORT=6379
TERM=xterm
REDIS_ENV_REDIS_DOWNLOAD_SHA=fc53e73ae7586bcdacb4b63875d1ff04f68c5474c1ddeda78f00e5ae2eed1bbb
REDIS_ENV_GOSU_VERSION=1.10
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
REDIS_ENV_REDIS_VERSION=4.0.11
_=/usr/bin/env

use redis-cli in 5.bash to report errors

root@24f9eeb3e8e6:/data-sharp redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Apr.12,2021

modify the configuration file "00-system.conf",
net.ipv4.ip_forward=1
solve the problem

Menu