连接在nginx docker容器上拒绝 [英] Connection refused on nginx docker container

查看:1423
本文介绍了连接在nginx docker容器上拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在OSX中安装了 Docker Toolbox ,并且我遵循了Docker的简单教程,关于部署Nginx

I've installed Docker Toolbox in OSX and I'm following Docker's simple tutorial on deploying Nginx.

我已执行docker运行并确认我的容器已创建:

I've executed docker run and confirmed that my container has been created:

docker run --name mynginx1 -P -d nginx
docker ps
40001fc50719  nginx  "nginx -g 'daemon off"  23 minutes ago  Up 23 minutes  0.0.0.0:32770->80/tcp, 0.0.0.0:32769->443/tcp  mynginx1

c $ c>,我得到连接被拒绝的错误:

however when I curl http://localhost:32770, I get a connection refused error:

curl: (7) Failed to connect to localhost port 32770: Connection refused

我正在努力看到我可能错过了这里。是否有额外的步骤,我需要执行,鉴于我在OSX?

I'm struggling to see what I could have missed here. Is there an extra step I need to perform, in light of me being on OSX?

推荐答案

问题是你的code> DOCKER_HOST 未设置为localhost,您将需要使用Docker-machine的IP地址,因为您使用Docker Toolbox:

The issue is that your DOCKER_HOST is not set to localhost, you will need to use the IP address of your docker-machine, since you are using Docker Toolbox:

docker-machine ip default #应该返回你的IP地址。

docker-machine ip default # should return your IP address.

请参阅 Docker Toolbox文档了解更多信息。

这篇关于连接在nginx docker容器上拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆