基于本教程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/(自动打开web浏览器)。redisinsight的运行状况检查http://localhost:8001/健康检查/正常。
![](https://i.stack.imgur.com/8StWf.png)
![](https://i.stack.imgur.com/nGL9l.png)
![](https://i.stack.imgur.com/FnJIx.png)
(我在这里也注意到https://donhuvy.github.io/redis/docker/2020/10/10/run-redis-on-docker.html )
如何将redisinsight与redis无缝连接?
更新:这是我的主机文件,这里似乎有问题(ip地址) `127.0.0.1` 对于Kubernetes,我真的不知道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
3条答案
按热度按时间ckx4rj1h1#
为了使容器能够相互访问,您应该首先将它们连接到同一网络。
之后打开redisinsight ui并编写
docker_redis_1
保持端口不变。您应该能够连接到redis容器。ivqmmu1c2#
redisinsight正在尝试连接到容器的本地主机。尝试键入
127.0.0.1
进入Host
现场。如果文件主机已更改,如有问题的更新信息,请使用
192.168.1.44
.ubof19bj3#
因为您没有提到容器的任何网络,所以它们连接到默认的网桥网络。了解更多
获取容器ip地址
输入终端
在以下位置使用ip地址:http://localhost:8001/(redisinsight)。
或
(不推荐)键入
IP address
你的主机将解决这个问题使用
ipconfig
或者ifconfig
基于你的操作系统来获取你的ip