How to determine Docker image size before being pulled?
We can search for available image files on the docker website like this:
- https://index.docker.io/search?q=ubuntu
How can I tell what the download size(s) will be prior to pulling?
docker.io pull [image]
docker
add a comment |
We can search for available image files on the docker website like this:
- https://index.docker.io/search?q=ubuntu
How can I tell what the download size(s) will be prior to pulling?
docker.io pull [image]
docker
1
Not a general answer, but looking at the way the stackbrew ubuntu images are built, you can guess a lower bound to the image size from the used tarballs. (For predictable bandwidth usage, you might just build the images yourself -- you'd then know how much is downloaded, i.e. just the tarball itself.)
– sr_
Jun 3 '14 at 6:58
add a comment |
We can search for available image files on the docker website like this:
- https://index.docker.io/search?q=ubuntu
How can I tell what the download size(s) will be prior to pulling?
docker.io pull [image]
docker
We can search for available image files on the docker website like this:
- https://index.docker.io/search?q=ubuntu
How can I tell what the download size(s) will be prior to pulling?
docker.io pull [image]
docker
docker
edited Jan 14 '18 at 17:57
Chris Stryczynski
634619
634619
asked Jun 3 '14 at 1:58
SeperoSepero
58931226
58931226
1
Not a general answer, but looking at the way the stackbrew ubuntu images are built, you can guess a lower bound to the image size from the used tarballs. (For predictable bandwidth usage, you might just build the images yourself -- you'd then know how much is downloaded, i.e. just the tarball itself.)
– sr_
Jun 3 '14 at 6:58
add a comment |
1
Not a general answer, but looking at the way the stackbrew ubuntu images are built, you can guess a lower bound to the image size from the used tarballs. (For predictable bandwidth usage, you might just build the images yourself -- you'd then know how much is downloaded, i.e. just the tarball itself.)
– sr_
Jun 3 '14 at 6:58
1
1
Not a general answer, but looking at the way the stackbrew ubuntu images are built, you can guess a lower bound to the image size from the used tarballs. (For predictable bandwidth usage, you might just build the images yourself -- you'd then know how much is downloaded, i.e. just the tarball itself.)
– sr_
Jun 3 '14 at 6:58
Not a general answer, but looking at the way the stackbrew ubuntu images are built, you can guess a lower bound to the image size from the used tarballs. (For predictable bandwidth usage, you might just build the images yourself -- you'd then know how much is downloaded, i.e. just the tarball itself.)
– sr_
Jun 3 '14 at 6:58
add a comment |
4 Answers
4
active
oldest
votes
Looking at the API for Docker, Docker Remote API v1.10, it doesn't appear there is any way to get the sizes of the images. Section "2.2 Images" shows the spec for how to query about images.
Example
GET /images/json?all=0 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]
But this query needs to go against an actual Docker instance. Here's an example showing how one could use the above RESTful query:
$ echo -e "GET /images/json HTTP/1.0rn" | nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 858
Connection: close
Date: Fri, 20 Dec 2013 16:02:41 GMT
[{"Repository":"ubuntu","Tag":"12.04","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"latest","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"precise","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"12.10","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135},
{"Repository":"ubuntu","Tag":"quantal","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135}]
I saw no way to query the public repositories using this particular RESTful call. The only other RESTful method that looked like you could query docker.io's images was via search, GET /images/search
, but the API doesn't show any size attributes being returned for this.
References
- DOCKER FROM A DISTANCE - THE REMOTE API
Thanks for the insights! Hopefully the docker team will start making this info available viadocker search
– Sepero
Jun 3 '14 at 7:20
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
add a comment |
This is not a direct answer to your question but I hope it will be helpful nonetheless.
In the disk-usage script
in my Docker experiments
I use something like this:
docker run --entrypoint=/bin/sh $image -c 'du -sh / 2>/dev/null | cut -f1'
So you can run, e.g.:
docker run --entrypoint=/bin/sh ubuntu -c 'du -sh / 2>/dev/null | cut -f1'
Or you can download that script: disk-usage
and run e.g. ./disk-usage "ubuntu busybox gcc"
to have the disk usage (as reported by du -sh
) displayed for those 3 images:
Image Disk usage
----- ----------
ubuntu 209M
busybox 2.6M
gcc 1.5G
Please note that it doesn't show the actual download required for any given image, and it will display the result after downloading the image, but it gives some idea on how bloated is a given image as compared to others.
You can run it on one machine to decide whether you want to download that images on other machines, or to use it at all.
add a comment |
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
add a comment |
- For image on Docker Hub:
curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=100" | jq -r '.results | select(.name == "<tag-name>") | .images[0].size' | numfmt --to=iec-i
For image on other registry like Microsoft Container Registry. I figure out 3 ways.
- Use
docker manifest inspect
to observe the manifest data, which can give you idea on how to gain the compressed size of the image.
docker manifest inspect -v <registry-domain>/<image-name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | numfmt --to=iec-i
To enable
docker manifest inspect
, edit~/.docker/config.json
file and setexperimental
toenable
.(Reference: docker manifest inspect)
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 save my-image:latest > my-image.tar
# Compress the .tar file
gzip my-image.tar
# Check the size of the compressed image
ls -lh my-image.tar.gz
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f134186%2fhow-to-determine-docker-image-size-before-being-pulled%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Looking at the API for Docker, Docker Remote API v1.10, it doesn't appear there is any way to get the sizes of the images. Section "2.2 Images" shows the spec for how to query about images.
Example
GET /images/json?all=0 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]
But this query needs to go against an actual Docker instance. Here's an example showing how one could use the above RESTful query:
$ echo -e "GET /images/json HTTP/1.0rn" | nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 858
Connection: close
Date: Fri, 20 Dec 2013 16:02:41 GMT
[{"Repository":"ubuntu","Tag":"12.04","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"latest","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"precise","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"12.10","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135},
{"Repository":"ubuntu","Tag":"quantal","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135}]
I saw no way to query the public repositories using this particular RESTful call. The only other RESTful method that looked like you could query docker.io's images was via search, GET /images/search
, but the API doesn't show any size attributes being returned for this.
References
- DOCKER FROM A DISTANCE - THE REMOTE API
Thanks for the insights! Hopefully the docker team will start making this info available viadocker search
– Sepero
Jun 3 '14 at 7:20
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
add a comment |
Looking at the API for Docker, Docker Remote API v1.10, it doesn't appear there is any way to get the sizes of the images. Section "2.2 Images" shows the spec for how to query about images.
Example
GET /images/json?all=0 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]
But this query needs to go against an actual Docker instance. Here's an example showing how one could use the above RESTful query:
$ echo -e "GET /images/json HTTP/1.0rn" | nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 858
Connection: close
Date: Fri, 20 Dec 2013 16:02:41 GMT
[{"Repository":"ubuntu","Tag":"12.04","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"latest","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"precise","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"12.10","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135},
{"Repository":"ubuntu","Tag":"quantal","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135}]
I saw no way to query the public repositories using this particular RESTful call. The only other RESTful method that looked like you could query docker.io's images was via search, GET /images/search
, but the API doesn't show any size attributes being returned for this.
References
- DOCKER FROM A DISTANCE - THE REMOTE API
Thanks for the insights! Hopefully the docker team will start making this info available viadocker search
– Sepero
Jun 3 '14 at 7:20
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
add a comment |
Looking at the API for Docker, Docker Remote API v1.10, it doesn't appear there is any way to get the sizes of the images. Section "2.2 Images" shows the spec for how to query about images.
Example
GET /images/json?all=0 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]
But this query needs to go against an actual Docker instance. Here's an example showing how one could use the above RESTful query:
$ echo -e "GET /images/json HTTP/1.0rn" | nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 858
Connection: close
Date: Fri, 20 Dec 2013 16:02:41 GMT
[{"Repository":"ubuntu","Tag":"12.04","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"latest","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"precise","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"12.10","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135},
{"Repository":"ubuntu","Tag":"quantal","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135}]
I saw no way to query the public repositories using this particular RESTful call. The only other RESTful method that looked like you could query docker.io's images was via search, GET /images/search
, but the API doesn't show any size attributes being returned for this.
References
- DOCKER FROM A DISTANCE - THE REMOTE API
Looking at the API for Docker, Docker Remote API v1.10, it doesn't appear there is any way to get the sizes of the images. Section "2.2 Images" shows the spec for how to query about images.
Example
GET /images/json?all=0 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]
But this query needs to go against an actual Docker instance. Here's an example showing how one could use the above RESTful query:
$ echo -e "GET /images/json HTTP/1.0rn" | nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 858
Connection: close
Date: Fri, 20 Dec 2013 16:02:41 GMT
[{"Repository":"ubuntu","Tag":"12.04","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"latest","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"precise","Id":"8dbd9e392...",
"Created":1365714795,"Size":131502179,"VirtualSize":131502179},
{"Repository":"ubuntu","Tag":"12.10","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135},
{"Repository":"ubuntu","Tag":"quantal","Id":"b750fe792...",
"Created":1364102658,"Size":24653,"VirtualSize":180116135}]
I saw no way to query the public repositories using this particular RESTful call. The only other RESTful method that looked like you could query docker.io's images was via search, GET /images/search
, but the API doesn't show any size attributes being returned for this.
References
- DOCKER FROM A DISTANCE - THE REMOTE API
answered Jun 3 '14 at 6:20
slm♦slm
253k71535687
253k71535687
Thanks for the insights! Hopefully the docker team will start making this info available viadocker search
– Sepero
Jun 3 '14 at 7:20
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
add a comment |
Thanks for the insights! Hopefully the docker team will start making this info available viadocker search
– Sepero
Jun 3 '14 at 7:20
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
Thanks for the insights! Hopefully the docker team will start making this info available via
docker search
– Sepero
Jun 3 '14 at 7:20
Thanks for the insights! Hopefully the docker team will start making this info available via
docker search
– Sepero
Jun 3 '14 at 7:20
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
@Sepero - yes I'm sure over time things such as this will get added. If this A has resolved your Q's please mark it as accepted so other's know your issue's have been resolved too.
– slm♦
Jun 3 '14 at 11:16
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
Awesome, exactly what I needed!
– Brady Dowling
Aug 16 '17 at 17:38
add a comment |
This is not a direct answer to your question but I hope it will be helpful nonetheless.
In the disk-usage script
in my Docker experiments
I use something like this:
docker run --entrypoint=/bin/sh $image -c 'du -sh / 2>/dev/null | cut -f1'
So you can run, e.g.:
docker run --entrypoint=/bin/sh ubuntu -c 'du -sh / 2>/dev/null | cut -f1'
Or you can download that script: disk-usage
and run e.g. ./disk-usage "ubuntu busybox gcc"
to have the disk usage (as reported by du -sh
) displayed for those 3 images:
Image Disk usage
----- ----------
ubuntu 209M
busybox 2.6M
gcc 1.5G
Please note that it doesn't show the actual download required for any given image, and it will display the result after downloading the image, but it gives some idea on how bloated is a given image as compared to others.
You can run it on one machine to decide whether you want to download that images on other machines, or to use it at all.
add a comment |
This is not a direct answer to your question but I hope it will be helpful nonetheless.
In the disk-usage script
in my Docker experiments
I use something like this:
docker run --entrypoint=/bin/sh $image -c 'du -sh / 2>/dev/null | cut -f1'
So you can run, e.g.:
docker run --entrypoint=/bin/sh ubuntu -c 'du -sh / 2>/dev/null | cut -f1'
Or you can download that script: disk-usage
and run e.g. ./disk-usage "ubuntu busybox gcc"
to have the disk usage (as reported by du -sh
) displayed for those 3 images:
Image Disk usage
----- ----------
ubuntu 209M
busybox 2.6M
gcc 1.5G
Please note that it doesn't show the actual download required for any given image, and it will display the result after downloading the image, but it gives some idea on how bloated is a given image as compared to others.
You can run it on one machine to decide whether you want to download that images on other machines, or to use it at all.
add a comment |
This is not a direct answer to your question but I hope it will be helpful nonetheless.
In the disk-usage script
in my Docker experiments
I use something like this:
docker run --entrypoint=/bin/sh $image -c 'du -sh / 2>/dev/null | cut -f1'
So you can run, e.g.:
docker run --entrypoint=/bin/sh ubuntu -c 'du -sh / 2>/dev/null | cut -f1'
Or you can download that script: disk-usage
and run e.g. ./disk-usage "ubuntu busybox gcc"
to have the disk usage (as reported by du -sh
) displayed for those 3 images:
Image Disk usage
----- ----------
ubuntu 209M
busybox 2.6M
gcc 1.5G
Please note that it doesn't show the actual download required for any given image, and it will display the result after downloading the image, but it gives some idea on how bloated is a given image as compared to others.
You can run it on one machine to decide whether you want to download that images on other machines, or to use it at all.
This is not a direct answer to your question but I hope it will be helpful nonetheless.
In the disk-usage script
in my Docker experiments
I use something like this:
docker run --entrypoint=/bin/sh $image -c 'du -sh / 2>/dev/null | cut -f1'
So you can run, e.g.:
docker run --entrypoint=/bin/sh ubuntu -c 'du -sh / 2>/dev/null | cut -f1'
Or you can download that script: disk-usage
and run e.g. ./disk-usage "ubuntu busybox gcc"
to have the disk usage (as reported by du -sh
) displayed for those 3 images:
Image Disk usage
----- ----------
ubuntu 209M
busybox 2.6M
gcc 1.5G
Please note that it doesn't show the actual download required for any given image, and it will display the result after downloading the image, but it gives some idea on how bloated is a given image as compared to others.
You can run it on one machine to decide whether you want to download that images on other machines, or to use it at all.
answered Mar 7 '15 at 3:17
rsprsp
2,5381147
2,5381147
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Jun 22 '17 at 7:28
Arif A.Arif A.
1214
1214
add a comment |
add a comment |
- For image on Docker Hub:
curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=100" | jq -r '.results | select(.name == "<tag-name>") | .images[0].size' | numfmt --to=iec-i
For image on other registry like Microsoft Container Registry. I figure out 3 ways.
- Use
docker manifest inspect
to observe the manifest data, which can give you idea on how to gain the compressed size of the image.
docker manifest inspect -v <registry-domain>/<image-name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | numfmt --to=iec-i
To enable
docker manifest inspect
, edit~/.docker/config.json
file and setexperimental
toenable
.(Reference: docker manifest inspect)
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 save my-image:latest > my-image.tar
# Compress the .tar file
gzip my-image.tar
# Check the size of the compressed image
ls -lh my-image.tar.gz
New contributor
add a comment |
- For image on Docker Hub:
curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=100" | jq -r '.results | select(.name == "<tag-name>") | .images[0].size' | numfmt --to=iec-i
For image on other registry like Microsoft Container Registry. I figure out 3 ways.
- Use
docker manifest inspect
to observe the manifest data, which can give you idea on how to gain the compressed size of the image.
docker manifest inspect -v <registry-domain>/<image-name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | numfmt --to=iec-i
To enable
docker manifest inspect
, edit~/.docker/config.json
file and setexperimental
toenable
.(Reference: docker manifest inspect)
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 save my-image:latest > my-image.tar
# Compress the .tar file
gzip my-image.tar
# Check the size of the compressed image
ls -lh my-image.tar.gz
New contributor
add a comment |
- For image on Docker Hub:
curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=100" | jq -r '.results | select(.name == "<tag-name>") | .images[0].size' | numfmt --to=iec-i
For image on other registry like Microsoft Container Registry. I figure out 3 ways.
- Use
docker manifest inspect
to observe the manifest data, which can give you idea on how to gain the compressed size of the image.
docker manifest inspect -v <registry-domain>/<image-name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | numfmt --to=iec-i
To enable
docker manifest inspect
, edit~/.docker/config.json
file and setexperimental
toenable
.(Reference: docker manifest inspect)
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 save my-image:latest > my-image.tar
# Compress the .tar file
gzip my-image.tar
# Check the size of the compressed image
ls -lh my-image.tar.gz
New contributor
- For image on Docker Hub:
curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=100" | jq -r '.results | select(.name == "<tag-name>") | .images[0].size' | numfmt --to=iec-i
For image on other registry like Microsoft Container Registry. I figure out 3 ways.
- Use
docker manifest inspect
to observe the manifest data, which can give you idea on how to gain the compressed size of the image.
docker manifest inspect -v <registry-domain>/<image-name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | numfmt --to=iec-i
To enable
docker manifest inspect
, edit~/.docker/config.json
file and setexperimental
toenable
.(Reference: docker manifest inspect)
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 save my-image:latest > my-image.tar
# Compress the .tar file
gzip my-image.tar
# Check the size of the compressed image
ls -lh my-image.tar.gz
New contributor
New contributor
answered 15 mins ago
Di LinDi Lin
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f134186%2fhow-to-determine-docker-image-size-before-being-pulled%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Not a general answer, but looking at the way the stackbrew ubuntu images are built, you can guess a lower bound to the image size from the used tarballs. (For predictable bandwidth usage, you might just build the images yourself -- you'd then know how much is downloaded, i.e. just the tarball itself.)
– sr_
Jun 3 '14 at 6:58