diff --git a/docker/api/build.py b/docker/api/build.py index c4fc37ec98..5db58382ba 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -286,10 +286,10 @@ def _set_auth_headers(self, headers): # If we don't have any auth data so far, try reloading the config # file one more time in case anything showed up in there. - if not self._auth_configs: + if not self._auth_configs or self._auth_configs.is_empty: log.debug("No auth config in memory - loading from filesystem") self._auth_configs = auth.load_config( - credsore_env=self.credsore_env + credstore_env=self.credstore_env ) # Send the full auth configuration (if any exists), since the build diff --git a/docker/api/daemon.py b/docker/api/daemon.py index a2936f2a0e..f715a131ad 100644 --- a/docker/api/daemon.py +++ b/docker/api/daemon.py @@ -127,7 +127,7 @@ def login(self, username, password=None, email=None, registry=None, self._auth_configs = auth.load_config( dockercfg_path, credstore_env=self.credstore_env ) - elif not self._auth_configs: + elif not self._auth_configs or self._auth_configs.is_empty: self._auth_configs = auth.load_config( credstore_env=self.credstore_env ) diff --git a/docker/auth.py b/docker/auth.py index c1b874f870..58b35eb491 100644 --- a/docker/auth.py +++ b/docker/auth.py @@ -39,7 +39,7 @@ def resolve_index_name(index_name): def get_config_header(client, registry): log.debug('Looking for auth config') - if not client._auth_configs: + if not client._auth_configs or client._auth_configs.is_empty: log.debug( "No auth config in memory - loading from filesystem" ) @@ -212,6 +212,12 @@ def creds_store(self): def cred_helpers(self): return self.get('credHelpers', {}) + @property + def is_empty(self): + return ( + not self.auths and not self.creds_store and not self.cred_helpers + ) + def resolve_authconfig(self, registry=None): """ Returns the authentication data from the given auth configuration for a