简体   繁体   English

Docker 说:无法建立连接,因为目标机器主动拒绝了它

[英]Docker says: No connection could be made because the target machine actively refused it

I was using docker everyday but today a problem occurred without changing anything.我每天都在使用 docker,但今天发生了一个问题,没有改变任何东西。 I opened docker terminal and tried to start one of my containers.我打开 docker 终端并尝试启动我的一个容器。 But it gave this error:"No connection could be made because the target machine actively refused it" I am using Windows 10.但它给出了这个错误:“无法建立连接,因为目标机器主动拒绝它”我使用的是 Windows 10。

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com


admin@samsung MINGW64 ~
$ docker ps
An error occurred trying to connect: Get http://127.0.0.1:2375/v1.22/containers/json: dial tcp 127.0.0.1:2375: connectex: No connection could be made because the target machine actively refused it.

admin@samsung MINGW64 ~
$ docker version
Client:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 22:37:33 2016
 OS/Arch:      windows/amd64
An error occurred trying to connect: Get http://127.0.0.1:2375/v1.22/version: dial tcp 127.0.0.1:2375: connectex: No connection could be made because the target machine actively refused it.
  1. Right-click on your PC右键单击您的 PC
  2. Properties特性
  3. Advanced system settings高级系统设置
  4. Environment Variables环境变量
  5. Add new Variable: DOCKER_HOST添加新变量: DOCKER_HOST
    Value: tcp://127.0.0.1:2375值:tcp://127.0.0.1:2375
  6. Run Docker Desktop运行 Docker 桌面
  7. bottom-right, right-click on Docker-Desktop右下角,右键单击 Docker-Desktop
  8. Settings设置
  9. Enable the following option: "Expose daemon on tcp://localhost:2375 without TLS"启用以下选项:“Expose daemon on tcp://localhost:2375 without TLS”

I've fixed that by going to Oracle VM VirtualBox Manager (could be searched in start menu), stopping the VM ( default in my case) and then running Docker Quickstart Terminal again.我通过转到Oracle VM VirtualBox Manager (可以在开始菜单中搜索)、停止 VM(在我的情况下为default )然后再次运行Docker Quickstart Terminal了这个问题。

Also, please refer to this answer.另外,请参考这个答案。

"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. “主动拒绝它”意味着当您尝试连接时主机发送了重置而不是确认。 It is therefore not a problem in your code.因此,这在您的代码中不是问题。 Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port.要么是防火墙阻止了连接,要么是托管服务的进程未在该端口上侦听。 This may be because it is not running at all or because it is listening on a different port.这可能是因为它根本没有运行,或者因为它正在侦听不同的端口。

Once you start the process hosting your service, try netstat -anb (requires admin privileges) to verify that it is running and listening on the expected port.启动托管服务的进程后,请尝试netstat -anb (需要管理员权限)以验证它是否正在运行并在预期端口上侦听。

I was also facing the same issue and even tried by stopping and then restarting the default machine.我也面临同样的问题,甚至尝试停止然后重新启动默认机器。

Solution: Finally, I restarted my system and then opened the new Docker quickstart terminal.解决方案:最后,我重新启动了系统,然后打开了新的 Docker 快速启动终端。 After that I ran "docker run hello-world" again and then it got connected and pulled the hello-world from library/hello-world.之后,我再次运行“docker run hello-world”,然后它连接并从 library/hello-world 中拉出 hello-world。

For me, this was caused by being connected to VPN.对我来说,这是由连接到 VPN 引起的。

Disconnect from VPN to allow a connecting to the local VirtualBox / Docker instance.断开与 VPN的连接以允许连接到本地 VirtualBox / Docker 实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM