mirror of https://github.com/docker/docker-py.git
Merge pull request #551 from docker/support_v2_private_registry
Modify expand_registry_url to support v2 private registries.
This commit is contained in:
commit
5b69cbf4ef
|
@ -29,7 +29,7 @@ DOCKER_CONFIG_FILENAME = '.dockercfg'
|
||||||
def expand_registry_url(hostname, insecure=False):
|
def expand_registry_url(hostname, insecure=False):
|
||||||
if hostname.startswith('http:') or hostname.startswith('https:'):
|
if hostname.startswith('http:') or hostname.startswith('https:'):
|
||||||
return hostname
|
return hostname
|
||||||
if utils.ping('https://' + hostname + '/v1/_ping'):
|
if utils.ping_registry('https://' + hostname):
|
||||||
return 'https://' + hostname
|
return 'https://' + hostname
|
||||||
elif insecure:
|
elif insecure:
|
||||||
return 'http://' + hostname
|
return 'http://' + hostname
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from .utils import (
|
from .utils import (
|
||||||
compare_version, convert_port_bindings, convert_volume_binds,
|
compare_version, convert_port_bindings, convert_volume_binds,
|
||||||
mkbuildcontext, ping, tar, parse_repository_tag, parse_host,
|
mkbuildcontext, tar, parse_repository_tag, parse_host,
|
||||||
kwargs_from_env, convert_filters, create_host_config,
|
kwargs_from_env, convert_filters, create_host_config,
|
||||||
create_container_config, parse_bytes
|
create_container_config, parse_bytes, ping_registry
|
||||||
) # flake8: noqa
|
) # flake8: noqa
|
||||||
|
|
|
@ -118,6 +118,10 @@ def compare_version(v1, v2):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def ping_registry(url):
|
||||||
|
return ping(url + '/v2/_ping') or ping(url + '/v1/_ping')
|
||||||
|
|
||||||
|
|
||||||
def ping(url):
|
def ping(url):
|
||||||
try:
|
try:
|
||||||
res = requests.get(url, timeout=3)
|
res = requests.get(url, timeout=3)
|
||||||
|
|
Loading…
Reference in New Issue