diff --git a/docker/models/secrets.py b/docker/models/secrets.py index ca11edeb08..5c17faa17e 100644 --- a/docker/models/secrets.py +++ b/docker/models/secrets.py @@ -4,14 +4,22 @@ class Secret(Model): """A secret.""" - id_attribute = 'ID' + id_attribute = 'Id' def __repr__(self): return "<%s: '%s'>" % (self.__class__.__name__, self.name) @property def name(self): - return self.attrs['Spec']['Name'] + """ + Create secret only returns Id field, so if the name field is not + present, it will show id value instead. + Issue #2025 + """ + if self.attrs.get('Spec', {}).get('Name'): + return self.attrs['Spec']['Name'] + + return self.id def remove(self): """