Skip to content

Instantly share code, notes, and snippets.

@vbatts
Last active August 29, 2015 13:58
Show Gist options
  • Save vbatts/10022595 to your computer and use it in GitHub Desktop.
Save vbatts/10022595 to your computer and use it in GitHub Desktop.
docker vs. registry: tar length discrepancy

Overview

there has been a 1024 byte discrepancy of the tar archive when pushed from a docker daemon to a docker-registry

Usage

$ sh repro.sh

or if you are testing a local build of docker

$ DOCKER=/home/vbatts/src/docker/docker/bundles/1.2.0-dev/dynbinary/docker-1.2.0-dev sh repro.sh

Example output

Pulling repository registry
e42d15ec8417: Download complete 
511136ea3c5a: Download complete 
1c9383292a8f: Download complete 
9942dd43ff21: Download complete 
d92c3c92fa73: Download complete 
0ea0d582fd90: Download complete 
cc58e55aa5a5: Download complete 
c4ff7513909d: Download complete 
2a03160a302f: Download complete 
e01f4e09782b: Download complete 
d45160452d3a: Download complete 
8c3e8f86ecaf: Download complete 
381802b245e1: Download complete 
b1b4fdadbf1b: Download complete 
bab893de1904: Download complete 
f68b51b69ed8: Download complete 
4eb56962f397: Download complete 
5e1179330f72: Download complete 
16731cff304b: Download complete 
Pulling repository busybox
a9eb17255234: Download complete 
511136ea3c5a: Download complete 
42eed7f1bf2a: Download complete 
120e218dd395: Download complete 
The push refers to a repository [0.0.0.0:49154/busybox] (len: 1)
Sending image list
Pushing repository 0.0.0.0:49154/busybox (1 tags)
511136ea3c5a: Image successfully pushed 
42eed7f1bf2a: Image successfully pushed 
120e218dd395: Image successfully pushed 
a9eb17255234: Image successfully pushed 
Pushing tag for rev [a9eb17255234] on {http://0.0.0.0:49154/v1/repositories/busybox/tags/latest}
/tmp/tmp.4stppw ~
INFO :: id: 42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229; registry size: 0; docker save size: 1024
INFO :: id: 120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16; registry size: 2642944; docker save size: 2643968
INFO :: id: 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158; registry size: 512; docker save size: 1536
INFO :: id: a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721; registry size: 0; docker save size: 1024
~
943b68be7e9f6ad00f0556c2caf2420357b715e4f2240b6e79fe841cf1e10075
NOTICE: remove [/tmp/tmp.4stppw] when done inspecting
#!/bin/sh
set -e
DOCKER=${DOCKER:-docker}
${DOCKER} pull registry:latest
d=$(mktemp -d)
c=$(${DOCKER} run -d -p 5000 -v $d:/tmp/registry registry:latest)
b=$(${DOCKER} port ${c} 5000)
${DOCKER} pull busybox:latest
${DOCKER} tag busybox:latest ${b}/busybox
${DOCKER} push ${b}/busybox
pushd $d
mkdir save
${DOCKER} save ${b}/busybox | tar -C ./save -x
# docker save leaves these files unreadable
sudo find . \( -type d -exec chmod 0755 "{}" \; \) \( -type f -exec chmod 0644 "{}" \; \)
for path in $(find ./images/ -mindepth 1 -type d) ; do
id=$(basename ${path})
reg_layer="./images/${id}/layer"
save_layer="./save/${id}/layer.tar"
reg_size=$(zcat ${reg_layer} | dd of=/dev/null 2>&1 | grep bytes | cut -d " " -f 1)
save_size=$(cat ${save_layer} | dd of=/dev/null 2>&1 | grep bytes | cut -d " " -f 1)
echo "INFO :: id: ${id}; registry size: ${reg_size}; docker save size: ${save_size}"
done
popd
${DOCKER} rm $(${DOCKER} kill ${c})
echo "NOTICE: remove [${d}] when done inspecting"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment