Jan Suchotzki
Jan Suchotzki

Reputation: 1426

What does virtual size of docker image mean?

When you type docker images it will show you which images are locally available and other information. Part of this information is the virtual size. What exactly is that?

I found a little explanation in GitHub Issues #22 on docker, but this still is not clear to me. What I really like to know is, the amount of bytes to be downloaded and how many bytes an images needs on my hard drive.

Additionally Docker Hub 2.0 has still another information. When you look to the Tags page of an image there is another value shown. At least this seems to be always much smaller compared to the information given by docker images.

Upvotes: 6

Views: 924

Answers (1)

tianon
tianon

Reputation: 1914

The "virtual size" refers to the total sum of the on-disk size of all the layers the image is composed of. For example, if you have two images, app-1 and app-2, and both are based on a common distro image/layer whose total size is 100MB, and app-1 adds an additional 10MB but app-2 adds an additional 20MB, the virtual sizes will be 110MB and 120MB respectively, but the total disk usage will only be 130MB since that base layer is shared between the two.

The transfer size is going to be less (in most cases by quite a bit) due to gzip compression being applied to the layers while in transit.

The extended details provided in https://github.com/docker-library/docs/blob/162cdda0b66dd62ea1cc80a64cb6c369e341adf4/irssi/tag-details.md#irssilatest might make this more concretely obvious. As you can see there, the virtual size (sum of all the on-disk layer sizes) of irssi:latest is 261.1MB, but the "Content-Length" (compressed size in-transit) is only 97.5MB, and that's assuming that you don't already have any of the layers, when it's fairly likely you already have that first layer downloaded, which accounts for 125.1MB of the virtual size and 51.4MB of the "Content-Length" (and it's likely you have it already because that top layer is debian:jessie, which is a common base for the top-level images).

irssi:latest

  • Total Virtual Size: 261.1 MB (261122797 bytes)
  • Total v2 Content-Length: 97.5 MB (97485603 bytes)

Layers (13)

6d1ae97ee388924068b7a4797d995d57d1e6194843e7e2178e592a880bf6c7ad
  • Created: Fri, 04 Dec 2015 19:27:57 GMT
  • Docker Version: 1.8.3
  • Virtual Size: 125.1 MB (125115267 bytes)
  • v2 Blob: sha256:d4bce7fd68df2e8bb04e317e7cb7899e981159a4da89339e38c8bf30e6c318f0
  • v2 Content-Length: 51.4 MB (51354256 bytes)
  • v2 Last-Modified: Fri, 04 Dec 2015 19:45:49 GMT
8b9a99209d5c8f3fc5b4c01573f0508d1ddaa01c4f83c587e03b67497566aab9

...

Upvotes: 5

Related Questions