根据本教程https://www.youtube.com/watch?v=XrFeRwJjWHI,我尝试在Docker中运行Redis。
文件docker-compose.yml

version: "3.8"

services:
  redis:
    image: redis
    volumes:
      - ./data:/data
    ports:
      - 6379:6379
docker pull redis
docker-compose up
docker-compose up -d
docker container ls
telnet localhost 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的互联网速度)下载,解压缩,安装并开始。
转到:http://localhost:8001/(自动打开网络浏览器)。 RedisInsight http:// localhost:8001 / healthcheck /的运行状况检查正常。
docker - Docker上的RedisInsight和Docker上的Redis:无法连接:错误99连接到本地主机:6379。无法分配请求的地址-LMLPHP
docker - Docker上的RedisInsight和Docker上的Redis:无法连接:错误99连接到本地主机:6379。无法分配请求的地址-LMLPHP
docker - Docker上的RedisInsight和Docker上的Redis:无法连接:错误99连接到本地主机:6379。无法分配请求的地址-LMLPHP
(我在这里也注意到https://donhuvy.github.io/redis/docker/2020/10/10/run-redis-on-docker.html)
如何将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字段中键入Host
如果文件主机已更改,例如相关的更新信息,请使用192.168.1.44

关于docker - Docker上的RedisInsight和Docker上的Redis:无法连接:错误99连接到本地主机:6379。无法分配请求的地址,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/64295255/

10-09 06:20
查看更多