J'e
J'e

Reputation: 3716

Get the size of an image using the Docker SDK for Python

How do I get the size of a docker image using the Docker SDK for Python?

import docker
client = docker.from_env()
some_image : docker.models.images.Image = client.images.list()[0]
# size of some_image?

As specified here, the regular docker API has some differences when getting the size from a registry or locally. I'll take either one.

Upvotes: 0

Views: 422

Answers (1)

J'e
J'e

Reputation: 3716

The size is listed in "attrs" json of the image.

import docker
client = docker.from_env()
some_image : docker.models.images.Image = client.images.list()[0]
some_image.attrs['Size'] # size in Bytes. 

Upvotes: 1

Related Questions