mirror of https://github.com/docker/docker-py.git
Merge 2bf5d56c73 into db7f8b8bb6
This commit is contained in:
commit
dac746bf78
|
|
@ -32,6 +32,12 @@ class Container(Model):
|
||||||
"""
|
"""
|
||||||
if self.attrs.get('Name') is not None:
|
if self.attrs.get('Name') is not None:
|
||||||
return self.attrs['Name'].lstrip('/')
|
return self.attrs['Name'].lstrip('/')
|
||||||
|
if self.attrs.get('Names') is not None:
|
||||||
|
stripped_names = [name.lstrip('/') for name in self.attrs['Names']]
|
||||||
|
for name in stripped_names:
|
||||||
|
if '/' not in name:
|
||||||
|
return name
|
||||||
|
return ','.join(stripped_names)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image(self):
|
def image(self):
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
||||||
def test_list_sparse(self):
|
def test_list_sparse(self):
|
||||||
client = docker.from_env(version=TEST_API_VERSION)
|
client = docker.from_env(version=TEST_API_VERSION)
|
||||||
container_id = client.containers.run(
|
container_id = client.containers.run(
|
||||||
"alpine", "sleep 300", detach=True).id
|
"alpine", "sleep 300", detach=True, name='a_container').id
|
||||||
self.tmp_containers.append(container_id)
|
self.tmp_containers.append(container_id)
|
||||||
containers = [c for c in client.containers.list(sparse=True) if c.id ==
|
containers = [c for c in client.containers.list(sparse=True) if c.id ==
|
||||||
container_id]
|
container_id]
|
||||||
|
|
@ -312,6 +312,7 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
||||||
assert container.attrs['Image'] == 'alpine'
|
assert container.attrs['Image'] == 'alpine'
|
||||||
assert container.status == 'running'
|
assert container.status == 'running'
|
||||||
assert container.image == client.images.get('alpine')
|
assert container.image == client.images.get('alpine')
|
||||||
|
assert container.name == 'a_container'
|
||||||
with pytest.raises(docker.errors.DockerException):
|
with pytest.raises(docker.errors.DockerException):
|
||||||
_ = container.labels
|
_ = container.labels
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue