Docker上的RedisInsight和Docker上的Redis:无法连接:连接到本地主机时出现错误99:6379。无法分配请求的地址

Docker上的RedisInsight和Docker上的Redis:无法连接:连接到本地主机时出现错误99:6379。无法分配请求的地址,docker,redis,docker-compose,docker-container,redisinsights,Docker,Redis,Docker Compose,Docker Container,Redisinsights,基于本教程,我尝试在Docker中运行Redis 文件docker compose.yml 版本:“3.8” 服务: redis: 图片:redis 卷数: -/数据:/data 端口: - 6379:6379 Telnet,键入PING,然后按Enter键(您将看不到文本),然后查看结果:PONG。键入quit退出 Microsoft Windows [Version 10.0.19041.508] (c) 2020 Microsoft Corporation. All rights res

基于本教程,我尝试在Docker中运行Redis

文件
docker compose.yml

版本:“3.8”
服务:
redis:
图片:redis
卷数:
-/数据:/data
端口:
- 6379:6379
Telnet,键入
PING
,然后按Enter键(您将看不到文本),然后查看结果:
PONG
。键入
quit
退出

Microsoft Windows [Version 10.0.19041.508]
(c) 2020 Microsoft Corporation. All rights reserved.

D:\docker>docker-compose stop redis
Stopping docker_redis_1 ... done

D:\docker>
看看是什么在运行

docker container ls
你会看到,docker redis被阻止了

docker image prune -a
docker-compose up
Docker RedisInsight

docker run -v redisinsight:/db -p 8001:8001 redislabs/redisinsight:latest
等待大约6分钟(以22:30的网速)进行下载、解压缩、安装和启动

转到:(自动打开web浏览器)。RedisInsight的运行状况检查http://localhost:8001/healthcheck/ 没关系

(我在这里也提到)

如何将RedisInsight与Redis无误连接

更新:这是我的主机文件,这里似乎有问题(Kubernetes的IP
127.0.0.1
,我真的不知道Kubernetes,我正在学习),但我不知道如何修复

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1    www.techsmith.com
127.0.0.1    activation.cloud.techsmith.com
127.0.0.1    oscount.techsmith.com
127.0.0.1    updater.techsmith.com
127.0.0.1    camtasiatudi.techsmith.com
127.0.0.1    tsccloud.cloudapp.net
127.0.0.1    assets.cloud.techsmith.com

# Added by Docker Desktop
192.168.1.44 host.docker.internal
192.168.1.44 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section


RedisInsight正在尝试连接到容器的本地主机。尝试在主机字段中键入
127.0.0.1


如果文件主机已更改,如有疑问的更新信息,请使用
192.168.1.44

使容器能够相互访问。您应首先将它们连接到同一网络

docker network create redis
docker network connect redis elastic_diffie
docker network connect redis docker_redis_1

然后打开RedisInsight UI,将
docker\u redis\u 1
写入主机并保持端口不变。您应该能够连接到您的redis容器。

因为您没有提到容器的任何网络,所以它们连接到默认网桥网络

获取容器IP地址的步骤

输入你的终端

#检查集装箱网络IP地址
docker容器检查-f“{range.NetworkSettings.Networks}}{{{.IPAddress}}{{end}”
在以下位置使用IP地址:http://localhost:8001/ (RedisInsight)

(不推荐)键入主机的
IP地址将解决此问题


根据您的操作系统使用
ipconfig
ifconfig
docker compose.yml中使用此设置获取您的IP

版本:“3.7”
服务:
redis:
图片:“redis:6.0.6”
端口:
-“127.0.0.1:6379:6379/tcp”
卷数:
-'redis_data:/data:rw'
健康检查:
测试:redis cli ping
间隔时间:3s
超时:5秒
重试次数:5次
Redisight:
图片:“redislabs/redisinsight:最新”
端口:
- '127.0.0.1:8001:8001'
您可以通过


这仍然是一个错误。我希望你能帮助我。这是我的主机文件似乎在这个IP有问题。让我知道如何修复。@DoNhuVy根据您的主机文件,您要查找的IP地址是:
192.168.1.44
这些容器是否在同一网络中运行?尝试列出网络和容器以查看它们是否在同一网络上如何列出网络和容器?您得到答案了吗?我不确定。您可以执行以下操作以列出具有docker的网络:
docker network ls
。要检查容器的网络,可以执行以下操作:
docker inspect c1-f“{{json.NetworkSettings.Networks}”
c1==容器的名称。
docker network create redis
docker network connect redis elastic_diffie
docker network connect redis docker_redis_1