且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Docker-无法连接到本地主机端口4000:连接被拒绝

更新时间:2021-08-15 07:44:13

我对docker不太熟悉,但是它听起来您的设置是这样的:您的docker实例正在虚拟机中运行,并且您正尝试从Windows计算机访问绑定到localhost(即vm)的应用程序。您会在curl上被拒绝的原因是,实际上在主机(Windows)的端口4000上没有监听。

I'm not very familiar with docker, but it sounds like your setup is such that your docker instance is running in a virtual machine, and you're trying to access an application bound to localhost (the vm) from your Windows machine. The reason you would get a refusal here from curl is because nothing is actually listening on port 4000 on the host (Windows).

尝试通过以下方式查找您的Docker实例正在使用的IP:

Try to find the IP that your docker instance is using by:

$ docker-machine ip default

现在您知道IP地址,请再次尝试curl。您甚至可以像下面这样在命令中对其进行求值:

Now that you know the IP address, try curl again. You can even have it evaluated within the command like so:

$ curl http:// $(docker-machine ip默认值):4000