How does one get the size of a Docker image before they pull it to their machine?
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
For images on other registry like Microsoft Container Registry
Push the image to Docker Hub and you can get the compressed size of the image on Docker Hub website.
Use
docker save
to save image to a .tar file and then compress it a .tar.gz file.Use
docker manifest inspect
to observe the manifest data, which shows you the compressed size of the image.You need to first enable it by editing
~/.docker/config.json
file and setexperimental
toenable
. Example:{ "experimental": "enabled" }
. More info at official docs.Issue
docker manifest inspect -v <registry-domain>/<image-name>
and see add thesize
for the layers but only for your specific architecture (e.g.amd64
).Noted:
alpine
linux containsarm
,amd64
and several architectures), then you'll get the total of those while in actual usagedocker
only uses the relevantarch
.Docker images have many layers so the total image size will depend on how many layers your image is using.
A good tool to visualize your images and it's layers (including total size) in your docker registry is this Image Layers from Century Link Labs
Github: imagelayers-graph
If you really look into the docker code for pull operation, I think your answer is there. If the image of the container is not cached, then during pulling of the image, docker first collects the information about the image from the registry like number of layers, size of each layers etc. etc.
I would refer to read this file.
https://github.com/moxiegirl/docker/blob/master/distribution/xfer/download.go
When you search for a docker image on Docker hub, there will be 2 tabs-
Repo Info
andTags
. Open Tags tab and you will see the sizes of all the types of images you can pull for that image.