summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorMilas Bowman <milas.bowman@docker.com>2022-07-29 15:28:16 -0400
committerGitHub <noreply@github.com>2022-07-29 15:28:16 -0400
commit868e996269b6934420f0cd2104621b6f45f668e5 (patch)
tree5b4f1b6ae2478e0528029489ed381c2353373d37 /docker
parent26753c81defff28a1a38a34788e9653c8eb87c3d (diff)
downloaddocker-py-868e996269b6934420f0cd2104621b6f45f668e5.tar.gz
model: add remove() to Image (#3026)
Allow an Image to be deleted by calling the remove() method on it, just like a Volume. Signed-off-by: Ahmon Dancy <dancy@dancysoft.com> Signed-off-by: Milas Bowman <milas.bowman@docker.com> Co-authored-by: Ahmon Dancy <dancy@dancysoft.com>
Diffstat (limited to 'docker')
-rw-r--r--docker/models/images.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/docker/models/images.py b/docker/models/images.py
index e247d35..79ccbe4 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -61,6 +61,24 @@ class Image(Model):
"""
return self.client.api.history(self.id)
+ def remove(self, force=False, noprune=False):
+ """
+ Remove this image.
+
+ Args:
+ force (bool): Force removal of the image
+ noprune (bool): Do not delete untagged parents
+
+ Raises:
+ :py:class:`docker.errors.APIError`
+ If the server returns an error.
+ """
+ return self.client.api.remove_image(
+ self.id,
+ force=force,
+ noprune=noprune,
+ )
+
def save(self, chunk_size=DEFAULT_DATA_CHUNK_SIZE, named=False):
"""
Get a tarball of an image. Similar to the ``docker save`` command.