diff --git a/docker/client.py b/docker/client.py
index fb186cc7..7d1f7c46 100644
--- a/docker/client.py
+++ b/docker/client.py
@@ -45,17 +45,17 @@ class Client(
                  timeout=constants.DEFAULT_TIMEOUT_SECONDS, tls=False):
         super(Client, self).__init__()
 
-        if tls and (not base_url or not base_url.startswith('https://')):
+        if tls and not base_url:
             raise errors.TLSParameterError(
-                'If using TLS, the base_url argument must begin with '
-                '"https://".')
+                'If using TLS, the base_url argument must be provided.'
+            )
 
         self.base_url = base_url
         self.timeout = timeout
 
         self._auth_configs = auth.load_config()
 
-        base_url = utils.parse_host(base_url, sys.platform)
+        base_url = utils.parse_host(base_url, sys.platform, tls=bool(tls))
         if base_url.startswith('http+unix://'):
             self._custom_adapter = unixconn.UnixAdapter(base_url, timeout)
             self.mount('http+docker://', self._custom_adapter)
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 1ce1867c..dc46f1ef 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -345,7 +345,7 @@ def parse_repository_tag(repo_name):
 # fd:// protocol unsupported (for obvious reasons)
 # Added support for http and https
 # Protocol translation: tcp -> http, unix -> http+unix
-def parse_host(addr, platform=None):
+def parse_host(addr, platform=None, tls=False):
     proto = "http+unix"
     host = DEFAULT_HTTP_HOST
     port = None
@@ -381,7 +381,7 @@ def parse_host(addr, platform=None):
             raise errors.DockerException(
                 "Invalid bind address protocol: {0}".format(addr)
             )
-        proto = "http"
+        proto = "https" if tls else "http"
 
     if proto != "http+unix" and ":" in addr:
         host_parts = addr.split(':')

Problem when using the DOCKER_HOST variable in combination with docker-compose and https://
Hi,

I'm trying to use docker & docker-compose with the DOCKER_HOST env-variable to control a remote docker-host.

at first I configured the variables on the docker client machine as follows:

    export DOCKER_CERT_PATH=/vagrant/docker
    export DOCKER_TLS_VERIFY=1
    export DOCKER_HOST=my-docker-vm.cloudapp.azure.com:2376

This lead to an error in docker-compose as discussed in this issue docker/compose#2634

Once I added the `https://` protocol prefix to the hostname the connection problem with docker-compose went away...

    export DOCKER_HOST=https://my-docker-vm.cloudapp.azure.com:2376

But with this format of the DOCKER_HOST variable now the docker CLI is complaining about the format...

    docker ps
    Invalid bind address format: https://my-docker-vm.cloudapp.azure.com:2376

I think this error is triggered here: https://github.com/docker/docker-py/blob/62d9964cc1881f6f3cd021594cd40fd80a8fc855/docker/utils/utils.py#L388

The code is not expecting to find two occurrences of double-dots `:` in the host variable, but for some reason it does.

PS: also the ambiguity of the two error messages in `utils.py` could be improved, since at L368 & at L388 both errors emit the same message, but for different reasons ;)

Thanks & Regards,
Wolfgang
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index 83d2a98d..63ea10e7 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -360,6 +360,11 @@ class ParseHostTest(base.BaseTestCase):
 
             assert parse_host(val, 'win32') == tcp_port
 
+    def test_parse_host_tls(self):
+        host_value = 'myhost.docker.net:3348'
+        expected_result = 'https://myhost.docker.net:3348'
+        self.assertEqual(parse_host(host_value, None, True), expected_result)
+
 
 class ParseRepositoryTagTest(base.BaseTestCase):
     sha = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/docker/docker-py.git@446e6d08dd569194a27bb354a184b7d94ecf5e48#egg=docker_py
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
requests==2.5.3
six==1.17.0
tomli==2.2.1
websocket_client==0.32.0

name: docker-py
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - requests==2.5.3
      - six==1.17.0
      - tomli==2.2.1
      - websocket-client==0.32.0
prefix: /opt/conda/envs/docker-py

tests/unit/utils_test.py::ParseHostTest::test_parse_host_tls
tests/unit/utils_test.py::HostConfigTest::test_create_endpoint_config_with_aliases tests/unit/utils_test.py::HostConfigTest::test_create_host_config_invalid_cpu_cfs_types tests/unit/utils_test.py::HostConfigTest::test_create_host_config_no_options tests/unit/utils_test.py::HostConfigTest::test_create_host_config_no_options_newer_api_version tests/unit/utils_test.py::HostConfigTest::test_create_host_config_with_cpu_period tests/unit/utils_test.py::HostConfigTest::test_create_host_config_with_cpu_quota tests/unit/utils_test.py::HostConfigTest::test_create_host_config_with_oom_kill_disable tests/unit/utils_test.py::UlimitTest::test_create_host_config_dict_ulimit tests/unit/utils_test.py::UlimitTest::test_create_host_config_dict_ulimit_capitals tests/unit/utils_test.py::UlimitTest::test_create_host_config_obj_ulimit tests/unit/utils_test.py::UlimitTest::test_ulimit_invalid_type tests/unit/utils_test.py::LogConfigTest::test_create_host_config_dict_logconfig tests/unit/utils_test.py::LogConfigTest::test_create_host_config_obj_logconfig tests/unit/utils_test.py::LogConfigTest::test_logconfig_invalid_config_type tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_empty tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_no_cert_path tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_tls tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_compact tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_complete tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_empty tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_list tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_no_mode tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_unicode_bytes_input tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_unicode_unicode_input tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_commented_line tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_invalid_line tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_proper tests/unit/utils_test.py::ParseHostTest::test_parse_host tests/unit/utils_test.py::ParseHostTest::test_parse_host_empty_value tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_image_no_tag tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_image_sha tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_image_tag tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_user_image_no_tag tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_user_image_tag tests/unit/utils_test.py::ParseRepositoryTagTest::test_private_reg_image_no_tag tests/unit/utils_test.py::ParseRepositoryTagTest::test_private_reg_image_sha tests/unit/utils_test.py::ParseRepositoryTagTest::test_private_reg_image_tag tests/unit/utils_test.py::ParseDeviceTest::test_dict tests/unit/utils_test.py::ParseDeviceTest::test_full_string_definition tests/unit/utils_test.py::ParseDeviceTest::test_hybrid_list tests/unit/utils_test.py::ParseDeviceTest::test_partial_string_definition tests/unit/utils_test.py::ParseDeviceTest::test_permissionless_string_definition tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_float tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_invalid tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_maxint tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_valid tests/unit/utils_test.py::UtilsTest::test_convert_filters tests/unit/utils_test.py::UtilsTest::test_create_ipam_config tests/unit/utils_test.py::UtilsTest::test_decode_json_header tests/unit/utils_test.py::SplitCommandTest::test_split_command_with_unicode tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_matching_internal_port_ranges tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_matching_internal_ports tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_nonmatching_internal_port_ranges tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_nonmatching_internal_ports tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_one_port tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_port_range tests/unit/utils_test.py::PortsTest::test_host_only_with_colon tests/unit/utils_test.py::PortsTest::test_non_matching_length_port_ranges tests/unit/utils_test.py::PortsTest::test_port_and_range_invalid tests/unit/utils_test.py::PortsTest::test_port_only_with_colon tests/unit/utils_test.py::PortsTest::test_split_port_invalid tests/unit/utils_test.py::PortsTest::test_split_port_no_host_port tests/unit/utils_test.py::PortsTest::test_split_port_range_no_host_port tests/unit/utils_test.py::PortsTest::test_split_port_range_with_host_ip_no_port tests/unit/utils_test.py::PortsTest::test_split_port_range_with_host_port tests/unit/utils_test.py::PortsTest::test_split_port_range_with_protocol tests/unit/utils_test.py::PortsTest::test_split_port_with_host_ip tests/unit/utils_test.py::PortsTest::test_split_port_with_host_ip_no_port tests/unit/utils_test.py::PortsTest::test_split_port_with_host_port tests/unit/utils_test.py::PortsTest::test_split_port_with_protocol tests/unit/utils_test.py::ExcludePathsTest::test_directory tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_single_exception tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_subdir_exception tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_trailing_slash tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_wildcard_exception tests/unit/utils_test.py::ExcludePathsTest::test_exclude_custom_dockerfile tests/unit/utils_test.py::ExcludePathsTest::test_exclude_dockerfile_dockerignore tests/unit/utils_test.py::ExcludePathsTest::test_no_dupes tests/unit/utils_test.py::ExcludePathsTest::test_no_excludes tests/unit/utils_test.py::ExcludePathsTest::test_question_mark tests/unit/utils_test.py::ExcludePathsTest::test_single_filename tests/unit/utils_test.py::ExcludePathsTest::test_single_filename_trailing_slash tests/unit/utils_test.py::ExcludePathsTest::test_single_subdir_single_filename tests/unit/utils_test.py::ExcludePathsTest::test_single_subdir_wildcard_filename tests/unit/utils_test.py::ExcludePathsTest::test_subdirectory tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_exclude tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_filename_end tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_filename_start tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_subdir_single_filename tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_subdir_wildcard_filename tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_with_exception tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_with_wildcard_exception tests/unit/utils_test.py::TarTest::test_tar_with_directory_symlinks tests/unit/utils_test.py::TarTest::test_tar_with_empty_directory tests/unit/utils_test.py::TarTest::test_tar_with_excludes tests/unit/utils_test.py::TarTest::test_tar_with_file_symlinks
docker/utils/utils.py docker/client.py
docker/utils/utils.py docker/client.py