gpt4 book ai didi

Centos7 上的 Docker : connection refused

转载 作者:行者123 更新时间:2023-12-02 20:47:07 24 4
gpt4 key购买 nike

我知道已经发布了一些关于类似问题的问题,但不幸的是我仍然无法使以下命令正常工作:

$sudo docker run hello-world

无法在本地找到图像“hello-world:latest”
docker:来自守护进程的错误响应:获取 https://registry-1.docker.io/v2/ :调用 tcp 52.54.216.153:443:getsockopt:连接被拒绝。
请参阅“docker run --help”。

我在 VirtualBox 上使用 CentOS7 虚拟机,并在系统级别配置了 HTTP/HTTPS/FTP 代理设置。此代理配置在 Chrome 和其他应用程序中运行良好。

浏览此论坛后,我尝试通过以下方式为 Docker 应用程序创建显式代理设置:

  • 创建一个 ~/.docker/config.json 文件,如 https://docs.docker.com/network/proxy/ 中所述然后执行“systemctl restart docker”
  • 创建/etc/systemd/system/docker.service.d/http-proxy.conf 然后执行“systemctl daemon-reload”和“systemctl restart docker”

  • 这是我的虚拟机上的 Docker 版本:

    $sudo docker 版本
    Client:
    Version: 18.03.1-ce
    API version: 1.37
    Go version: go1.9.5
    Git commit: 9ee9f40
    Built: Thu Apr 26 07:20:16 2018
    OS/Arch: linux/amd64
    Experimental: false
    Orchestrator: swarm

    Server:
    Engine:
    Version: 18.03.1-ce
    API version: 1.37 (minimum version 1.12)
    Go version: go1.9.5
    Git commit: 9ee9f40
    Built: Thu Apr 26 07:23:58 2018
    OS/Arch: linux/amd64
    Experimental: false

    $curl -v https://registry-1.docker.io/v2/
    * About to connect() to proxy XXX port 8012 (#0)
    ...
    >
    < HTTP/1.1 200 Connection established
    <
    * Proxy replied OK to CONNECT request
    * Initializing NSS with certpath: sql:/etc/pki/nssdb
    * CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
    * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    * Server certificate:
    * subject: CN=*.docker.io
    * start date: Aug 02 00:00:00 2017 GMT
    * expire date: Sep 02 12:00:00 2018 GMT
    * common name: *.docker.io
    * issuer: CN=Amazon,OU=Server CA 1B,O=Amazon,C=US
    > GET /v2/ HTTP/1.1
    > User-Agent: curl/7.29.0
    > Host: registry-1.docker.io
    > Accept: */*
    >
    < HTTP/1.1 401 Unauthorized
    < Content-Type: application/json; charset=utf-8
    < Docker-Distribution-Api-Version: registry/2.0
    < Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io"
    < Date: Fri, 08 Jun 2018 16:00:17 GMT
    < Content-Length: 87
    < Strict-Transport-Security: max-age=31536000
    <
    {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
    * Connection #0 to host XXX left intact

    $curl -v https://54.152.209.167
       ...
    ...
    < HTTP/1.1 200 Connection established
    <
    * Proxy replied OK to CONNECT request
    * Initializing NSS with certpath: sql:/etc/pki/nssdb
    * CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
    * Server certificate:
    * subject: CN=*.docker.io
    * start date: Aug 02 00:00:00 2017 GMT
    * expire date: Sep 02 12:00:00 2018 GMT
    * common name: *.docker.io
    * issuer: CN=Amazon,OU=Server CA 1B,O=Amazon,C=US
    * NSS error -12276 (SSL_ERROR_BAD_CERT_DOMAIN)
    * Unable to communicate securely with peer: requested domain name does not match the server's certificate.
    * Closing connection 0
    curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

    最佳答案

    https://docs.docker.com/config/daemon/systemd/#httphttps-proxy 中所述,以下命令解决了我的问题。它有点迷失在文档中,IMO。

    $ sudo mkdir -p /etc/systemd/system/docker.service.d

    vi /etc/systemd/system/docker.service.d/http-proxy.conf
    [Service]
    Environment="http://IP:PORT/"

    vi /etc/systemd/system/docker.service.d/https-proxy.conf
    [Service]
    Environment="http://IP:PORT/"

    $ sudo systemctl daemon-reload
    $ sudo systemctl restart docker
    $ systemctl show --property=Environment docker
    Environment=HTTP_PROXY=http://"http://IP:PORT/"

    关于Centos7 上的 Docker : connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50764241/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com