REDIS 无法在 Ubuntu Docker 容器内连接

huangapple go评论55阅读模式
英文:

REDIS not able to connect inside Ubuntu Docker Container

问题

我有Mac,并在上面安装了Docker。
我已经从最新的Ubuntu镜像创建了一个容器。

这是我的Docker命令:
docker run -it --name ubuntu-container -p 6379:6379 ubuntu /bin/bash

现在在Ubuntu容器内部,我正在尝试这样做:

apt-get update
apt-get install -y redis-tools

然而,尽管在Ubuntu容器内成功安装了Redis,但我无法运行Redis。

root@14d6783b73b3:/# redis-cli ping
无法连接到Redis 127.0.0.1:6379:连接被拒绝

由于我对Docker和Redis都不熟悉,我无法理解根本原因。

英文:

I have mac and installed docker on it.
I have created a container from latest ubuntu image.

This is my docker command:
docker run -it --name ubuntu-container -p 6379:6379 ubuntu /bin/bash

Now inside ubuntu container I am trying this

apt-get update
apt-get install -y redis-tools

However, I am not able to run redis after successfully installing it inside Ubuntu Container.

root@14d6783b73b3:/# redis-cli ping
Could not connect to Redis at 127.0.0.1:6379: Connection refused

Since, I am new to docker and Redis, I am not able to understand the root cause itself.

答案1

得分: 0

我错过了完全安装 redis。
这是命令

RUN apt-get install redis

由于未安装 redis-server,它显示无法连接到 127.0.0.1:6379 的 Redis。

英文:

I missed to install redis completely.
This is the command

RUN apt-get install redis

Since redis-server was not installed, it was saying that Could not connect to Redis at 127.0.0.1:6379.

huangapple
  • 本文由 发表于 2023年6月19日 03:06:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76502135.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定