diff options
author | Joffrey F <f.joffrey@gmail.com> | 2018-02-20 15:01:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-20 15:01:13 -0800 |
commit | 759833c174902644f60632324f19422fd4744867 (patch) | |
tree | c3cbdc5598ff184b4d5fdbc3fc1c3abfe0f76413 | |
parent | ba0e5332de2fb032b5b21e8e2835244152927c0f (diff) | |
parent | cc455d7fd5ac8d192e64965f68ecea74dca011de (diff) | |
download | docker-py-759833c174902644f60632324f19422fd4744867.tar.gz |
Merge pull request #1919 from docker/1912-pull-sha-tag
Fix DockerClient pull bug when pulling image by digest
-rw-r--r-- | docker/models/images.py | 4 | ||||
-rw-r--r-- | tests/integration/models_images_test.py | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/docker/models/images.py b/docker/models/images.py index d604f7c..58d5d93 100644 --- a/docker/models/images.py +++ b/docker/models/images.py @@ -314,7 +314,9 @@ class ImageCollection(Collection): self.client.api.pull(repository, tag=tag, **kwargs) if tag: - return self.get('{0}:{1}'.format(repository, tag)) + return self.get('{0}{2}{1}'.format( + repository, tag, '@' if tag.startswith('sha256:') else ':' + )) return self.list(repository) def push(self, repository, tag=None, **kwargs): diff --git a/tests/integration/models_images_test.py b/tests/integration/models_images_test.py index 2fa71a7..ae735ba 100644 --- a/tests/integration/models_images_test.py +++ b/tests/integration/models_images_test.py @@ -74,6 +74,15 @@ class ImageCollectionTest(BaseIntegrationTest): image = client.images.pull('alpine', tag='3.3') assert 'alpine:3.3' in image.attrs['RepoTags'] + def test_pull_with_sha(self): + image_ref = ( + 'hello-world@sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b95' + '59b27182d3fa80ce3f7' + ) + client = docker.from_env(version=TEST_API_VERSION) + image = client.images.pull(image_ref) + assert image_ref in image.attrs['RepoDigests'] + def test_pull_multiple(self): client = docker.from_env(version=TEST_API_VERSION) images = client.images.pull('hello-world') |