Docker连接问题-拒绝连接 [英] Docker connection issues - refused to connect
问题描述
我正在使用Mac OSX,并且在 Docker教程的第4部分中,但是我无法通过Web浏览器访问该网站。当我访问 docker-machine ls
命令提供的IP地址时,出现无法访问此站点的消息。错误。如果我指定端口2377,例如 http://192.168.99.100:2377/
(也使用端口2376),我至少可以连接,但结果为 192.168 .99.100发送了无效响应错误消息。
I'm using Mac OSX and I'm on part 4 of the Docker tutorial, but I cannot access the site through my web browser. When I visit either IP address given from the docker-machine ls
command I get a "this site can't be reached" error. If I specify port 2377, such as http://192.168.99.100:2377/
(also used port 2376) I can at least connect but it results in a "192.168.99.100 sent an invalid response" error message.
当我尝试对端口80和8080进行卷曲请求时,都会失败
When I try a curl request to both port 80 and 8080 it fails
curl http://192.168.99.100:80
curl: (7) Failed to connect to 192.168.99.100 port 80: Connection refused
如果我指定端口2376或2377,它将连接,但是我没有收到任何内容,这似乎与无效响应消息一致。从我的Web浏览器直接访问时出现错误
If I specify port 2376 or 2377 it will connect, but I don't get any content back, which seems to coincide with the "invalid response" error I get when visiting directly from my web browser
curl --verbose 192.168.99.100:2376
* Rebuilt URL to: 192.168.99.100:2376/
* Trying 192.168.99.100...
* TCP_NODELAY set
* Connected to 192.168.99.100 (192.168.99.100) port 2376 (#0)
> GET / HTTP/1.1
> Host: 192.168.99.100:2376
> User-Agent: curl/7.54.0
> Accept: */*
>
* Connection #0 to host 192.168.99.100 left intact
这是我运行时的输出 docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
myvm1 * virtualbox Running tcp://192.168.99.100:2376 v18.06.1-ce
myvm2 - virtualbox Running tcp://192.168.99.101:2376 v18.06.1-ce
我认为我的虚拟机存在端口映射问题,但是我不确定该怎么办。我尝试此问题中可接受的答案,但是仍然没有运气。
I think I have a port mapping issue with the VM's, but I'm not sure what to do. I tried the accepted answer in this question, but still no luck.
更新
我尝试按照此帖子,但有也没有运气。我添加了以下内容,并在VirtualBox管理器中验证了转发规则是否存在
I tried port forwarding as suggested in this post, but had no luck with that either. I added the following and verified in the VirtualBox manager that the forwarding rules are present
VBoxManage controlvm "myvm1" natpf1 "tcp-port8000,tcp,,80,,80";
VBoxManage controlvm "myvm2" natpf1 "tcp-port8000,tcp,,80,,80";
我还为两个虚拟机分别添加了端口7946 TCP / UDP和端口4789 UDP的转发
I've also added forwarding for port 7946 TCP/UDP and Port 4789 UDP to each of the two vm's
推荐答案
我今天在研究第4部分时遇到了同样的问题。在寻找解决方案很长时间后仍无法正常工作,然后我检查了 docker-compose.yml
文件以查看端口映射并找到正确的端口。对我来说是 curl -v http://192.168.99.100:4000
,它的工作原理是:
I came across the same problem today when study part4. After a long time searching for solutions but didn't work, then I checked my docker-compose.yml
file to see the ports mapping and found the right port. For me is curl -v http://192.168.99.100:4000
, and it worked:
这篇关于Docker连接问题-拒绝连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!