Skip to content

feat(volumes): add missing labels attribute #3330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docker/models/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ def name(self):
"""The name of the volume."""
return self.attrs['Name']

@property
def labels(self):
"""
The labels of a volume as dictionary.
"""
try:
result = self.attrs['Config'].get('Labels')
return result or {}
except KeyError as ke:
raise DockerException(
'Label data is not available for sparse objects. Call reload()'
' to retrieve all information'
) from ke

def remove(self, force=False):
"""
Remove this volume.
Expand Down