加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

无法使用boot2docker连接到作为容器运行的redis

发布时间:2020-12-16 03:36:23 所属栏目:安全 来源:网络整理
导读:在我的MBP上,安装了最新的boot2docker,我有以下Dockerfile: FROM redis:3.0.3CMD redis-server --bind 0.0.0.0 我执行以下操作: docker build .docker run --rm ba09b207db42 # where ba09b207db42 is the container id returned by the build command 然

在我的MBP上,安装了最新的boot2docker,我有以下Dockerfile:

FROM redis:3.0.3
CMD redis-server --bind 0.0.0.0

我执行以下操作:

docker build .
docker run --rm ba09b207db42 # where ba09b207db42 is the container id returned by the build command

然后我跑:

redis-cli -h `boot2docker ip`

我收到错误:

Could not connect to Redis at 192.168.59.103:6379: Connection refused

我错过了什么?

最佳答案
你忘了揭露这个港口.只需像这样运行容器:

docker run --rm -p 6379:6379 ba09b207db42

另外:

>您可以为图像命名,这样您就不需要使用ID:docker build -t myimage.
>然后你可以在后台启动容器,这样它就不会“阻塞”你的终端:docker run –name mycontainer -d -p 6379:6379 myimage

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读