Proper way to list container's "bind"-type volumes, ie. bind mounts?
Open
Nobody has claimed this yet.
kind/question
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
It's fairly easy to go through container.attrs to find its bind mounts.
def get_bind_mounts(container):
bind_mounts = []
for mount in container.attrs['Mounts']:
if mount['Type'] == 'bind':
bind_mounts.append(mount)
return bind_mounts
Or more succinctly:
def get_bind_mounts(container):
return [mount for mount in container.attrs['Mounts'] if mount['Type'] == 'bind']
Is there some more proper way to do this in docker-py? I looked through the docs, and don't see anything better. Perhaps a new container attribute/property, bind_mounts could be added that encapsulates this?
class Container(Model):
...
@property
def bind_mounts(self):
"""
List of the bind mounts of the container.
"""
return [mount for mount in container.attrs['Mounts'] if mount['Type'] == 'bind']
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by checking the Container model and its existing attrs-based properties. Compare the proposed bind_mounts property with the current Mounts data and surrounding API conventions; done means exposing bind-type mounts through a documented container attribute without changing existing access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100