Docker无法使用localhost:5000连接到本地注册表

时间:2018-01-17 10:35:38

标签: docker docker-registry

我正在关注Docker页面以运行本地注册表(https://docs.docker.com/registry/deploying/#run-a-local-registry)。注册表容器正在运行,但是当我尝试docker push localhost:5000/nginx时,我收到此错误:

Get https://localhost:5000/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

但是,我可以使用docker push 127.0.0.1:5000/nginx推送。

有关为什么这不起作用的任何建议?

编辑:

这是我的/etc/resolve.conf

domain bskyb.com
nameserver 172.20.220.26
nameserver 172.20.220.25
nameserver 10.5.212.21

我跑的命令:

[mwa51@OSTML0253700 ~] 2018-01-17 16:16:08$ docker push localhost:5000/nginx
The push refers to repository [localhost:5000/nginx]
Get https://localhost:5000/v2/: net/http: request canceled while 
waiting for connection (Client.Timeout exceeded while awaiting headers)
[mwa51@OSTML0253700 ~] 2018-01-17 16:16:31$

[mwa51@OSTML0253700 ~] 2018-01-17 16:16:31$ docker push 127.0.0.1:5000/nginx
The push refers to repository [127.0.0.1:5000/nginx]
a103d141fc98: Layer already exists
73e2bd445514: Layer already exists
2ec5c0a4cb57: Layer already exists
1.13: digest: 
sha256:926b086e1234b6ae9a11589c4cece66b267890d24d1da388c96dd8795b2ffcfb 
size: 948
a103d141fc98: Layer already exists
73e2bd445514: Layer already exists
2ec5c0a4cb57: Layer already exists
latest: digest: 
sha256:926b086e1234b6ae9a11589c4cece66b267890d24d1da388c96dd8795b2ffcfb 
size: 948
[mwa51@OSTML0253700 ~] 2018-01-17 16:17:59$

docker inspect registry的输出:

[
{
    "Id": "bc9d9dd7e6d07d36176a542814375230c1d2e1f154993b832485f0b61af8c9d7",
    "Created": "2018-01-17T10:16:01.269327669Z",
    "Path": "/entrypoint.sh",
    "Args": [
        "/etc/docker/registry/config.yml"
    ],
    "State": {
        "Status": "running",
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 2431,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2018-01-17T16:15:32.851068237Z",
        "FinishedAt": "2018-01-17T16:15:31.007531371Z"
    },
    "Image": "sha256:d1fd7d86a8257f3404f92c4474fb3353076883062d64a09232d95d940627459d",
    "ResolvConfPath": "/var/lib/docker/containers/bc9d9dd7e6d07d36176a542814375230c1d2e1f154993b832485f0b61af8c9d7/resolv.conf",
    "HostnamePath": "/var/lib/docker/containers/bc9d9dd7e6d07d36176a542814375230c1d2e1f154993b832485f0b61af8c9d7/hostname",
    "HostsPath": "/var/lib/docker/containers/bc9d9dd7e6d07d36176a542814375230c1d2e1f154993b832485f0b61af8c9d7/hosts",
    "LogPath": "/var/lib/docker/containers/bc9d9dd7e6d07d36176a542814375230c1d2e1f154993b832485f0b61af8c9d7/bc9d9dd7e6d07d36176a542814375230c1d2e1f154993b832485f0b61af8c9d7-json.log",
    "Name": "/registry",
    "RestartCount": 0,
    "Driver": "overlay2",
    "Platform": "linux",
    "MountLabel": "",
    "ProcessLabel": "",
    "AppArmorProfile": "",
    "ExecIDs": null,
    "HostConfig": {
        "Binds": null,
        "ContainerIDFile": "",
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "NetworkMode": "default",
        "PortBindings": {
            "5000/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "5000"
                }
            ]
        },
        "RestartPolicy": {
            "Name": "always",
            "MaximumRetryCount": 0
        },
        "AutoRemove": false,
        "VolumeDriver": "",
        "VolumesFrom": null,
        "CapAdd": null,
        "CapDrop": null,
        "Dns": [],
        "DnsOptions": [],
        "DnsSearch": [],
        "ExtraHosts": null,
        "GroupAdd": null,
        "IpcMode": "shareable",
        "Cgroup": "",
        "Links": null,
        "OomScoreAdj": 0,
        "PidMode": "",
        "Privileged": false,
        "PublishAllPorts": false,
        "ReadonlyRootfs": false,
        "SecurityOpt": null,
        "UTSMode": "",
        "UsernsMode": "",
        "ShmSize": 67108864,
        "Runtime": "runc",
        "ConsoleSize": [
            0,
            0
        ],
        "Isolation": "",
        "CpuShares": 0,
        "Memory": 0,
        "NanoCpus": 0,
        "CgroupParent": "",
        "BlkioWeight": 0,
        "BlkioWeightDevice": [],
        "BlkioDeviceReadBps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteIOps": null,
        "CpuPeriod": 0,
        "CpuQuota": 0,
        "CpuRealtimePeriod": 0,
        "CpuRealtimeRuntime": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "Devices": [],
        "DeviceCgroupRules": null,
        "DiskQuota": 0,
        "KernelMemory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "MemorySwappiness": null,
        "OomKillDisable": false,
        "PidsLimit": 0,
        "Ulimits": null,
        "CpuCount": 0,
        "CpuPercent": 0,
        "IOMaximumIOps": 0,
        "IOMaximumBandwidth": 0
    },
    "GraphDriver": {
        "Data": {
            "LowerDir": "/var/lib/docker/overlay2/cc234dacc7f73dbbb58dbab1ca0109e57d4a470c225e20daf69678a9c53cb8e2-init/diff:/var/lib/docker/overlay2/7acfd81c53735574cf334d7bb4779136cc8a510886105850c12af7cf785d56a5/diff:/var/lib/docker/overlay2/462af7abc4dc1df8e7760d274616fc98ec2484450ef92a38702370696c6b2e77/diff:/var/lib/docker/overlay2/2e74aa672b9a2f6fef960d9411725ffbbf0b0c233326915f089da46d597c8888/diff:/var/lib/docker/overlay2/37b9a8f667053beee899b031cec8e473f0273b3582ea20e4bea2477737bf0065/diff:/var/lib/docker/overlay2/1508860708a3fb5c720eee143063f02c852548e9f608b4e56470cba86d2b98a9/diff",
            "MergedDir": "/var/lib/docker/overlay2/cc234dacc7f73dbbb58dbab1ca0109e57d4a470c225e20daf69678a9c53cb8e2/merged",
            "UpperDir": "/var/lib/docker/overlay2/cc234dacc7f73dbbb58dbab1ca0109e57d4a470c225e20daf69678a9c53cb8e2/diff",
            "WorkDir": "/var/lib/docker/overlay2/cc234dacc7f73dbbb58dbab1ca0109e57d4a470c225e20daf69678a9c53cb8e2/work"
        },
        "Name": "overlay2"
    },
    "Mounts": [
        {
            "Type": "volume",
            "Name": "9f79a52daf7489c22409cf1629d01367d300a7f2519d3861579e43c73735a332",
            "Source": "/var/lib/docker/volumes/9f79a52daf7489c22409cf1629d01367d300a7f2519d3861579e43c73735a332/_data",
            "Destination": "/var/lib/registry",
            "Driver": "local",
            "Mode": "",
            "RW": true,
            "Propagation": ""
        }
    ],
    "Config": {
        "Hostname": "bc9d9dd7e6d0",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "ExposedPorts": {
            "5000/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Cmd": [
            "/etc/docker/registry/config.yml"
        ],
        "ArgsEscaped": true,
        "Image": "registry:2",
        "Volumes": {
            "/var/lib/registry": {}
        },
        "WorkingDir": "",
        "Entrypoint": [
            "/entrypoint.sh"
        ],
        "OnBuild": null,
        "Labels": {}
    },
    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "95e9979b7c9a9081262252d595c39b1601062f549b1ba16c7ac4fd7e1b5b04e8",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "5000/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "5000"
                }
            ]
        },
        "SandboxKey": "/var/run/docker/netns/95e9979b7c9a",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "d55c67127f6fcb6a29c9aafcf3eda3f641f0854f2ae1054469b25142bb0f5f15",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "172.17.0.2",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "MacAddress": "02:42:ac:11:00:02",
        "Networks": {
            "bridge": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": null,
                "NetworkID": "4dfe4b88f1906649d86797d7980908b7a6b5a5dadc40d9117340de6fd115e0f4",
                "EndpointID": "d55c67127f6fcb6a29c9aafcf3eda3f641f0854f2ae1054469b25142bb0f5f15",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:02",
                "DriverOpts": null
            }
        }
    }
}
]

还有:

[mwa51@OSTML0253700 ~] 2018-01-17 16:21:28$ echo $DOCKER_HOST

返回空白

0 个答案:

没有答案