无法从Docker连接到Redis

时间:2018-12-02 17:57:17

标签: docker redis docker-compose

类似的东西(Unable to connect to MYSQL from Docker Instanceredis connect timeout to remote server in a dockerCalling redis-cli in docker-compose setup)我试图在Docker上运行Redis。

我这样启动 Docker服务docker run --name some-redis -d redis

输出:

docker run --name some-redis -d redis
d2ea8a77ba543b3e85020de6bc450e0d50ce9f60e0307e52fd4ae394bd29722

我使用

重新验证
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

当我执行以下命令时,它不起作用

docker exec -it redis redis-cli
Error response from daemon: No such container: redis

1 个答案:

答案 0 :(得分:2)

您将容器命名为(\b(?:19\d{2}|20[0-4]\d|2050)\b),并尝试使用名称(?!.*(?1))进行连接。

尝试regex101