问题
Something simillar (Unable to connect to MYSQL from Docker Instance and redis connect timeout to remote server in a docker and Calling redis-cli in docker-compose setup) I tried to run for the Redis on Docker.
I start the Docker service like this: docker run --name some-redis -d redis
Output:
docker run --name some-redis -d redis
d2ea8a77ba543b3e85020de6bc450e0d50ce9f60e0307e52fd4ae394bd29722
I re-verified using
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d2ea8a77ba54 redis "docker-entrypoint.sh" 6 minutes ago Up 6 minutes 6379/tcp some-redis
1be4f5dde2fb mysql/mysql-server:latest "/entrypoint.sh mysql" About an hour ago Up About an hour (healthy) 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
e7d9e3713f5c ubuntu "/bin/bash" 6 days ago Up 6 days angry_hodgkin
When I execute the below commands, its not working
docker exec -it redis redis-cli
Error response from daemon: No such container: redis
回答1:
You named your container some-redis and are trying to connect with the name redis.
Try docker exec -it some-redis redis-cli
来源:https://stackoverflow.com/questions/53583036/unable-to-connect-to-redis-from-docker