Search code examples
dockerdocker-machinewindows-serverwindows-server-2022

Connection refused when pulling docker image on windows server


After installing docker on a windows server i got the following error when pulling a image with docker run hello-world command:

Error response from daemon: Get https://hub.docker.com/v2/: dial tcp 52.6.16.15:443: connectex: No connection could be made because the target machine actively refused it.


Solution

  • The problem was that the proxy was blocking the request.

    After some headaches, i finally got how to setup up proxy for docker on windows server from the right guide:

    Using powershell in elevated mode:

    1. Set environment variable to HTTP_PROXY environment variable
    [Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://username:password@proxy:port/", [EnvironmentVariableTarget]::Machine)
    

    May not need to specify credentials, if your proxy don't require it.

    1. Restart docker
     Restart-Service docker
    

    Now it should run:

    docker run hello-world