-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Description
When creating a Docker image that was almost, but not quite, 1 billion bytes in size, I noticed that docker image ls reported the size as 1e+03MB instead of 1000MB or 1.0GB. I figure that what happened is that the image was less than 1000MB so it didn't get reported as 1.0GB, but then since it was more than 999.5MB, it didn't get reported as 999MB either. This isn't really a problem for me, but it was slightly jarring, and I could conceive of a possible issue where someone's script designed to parse the output of docker image ls might barf on an unexpected format for image size.
I did not find any duplicate issues reporting this, probably because it's rare to actually trigger the conditions for this to happen, so I figured I'd report it so that someone can figure out a fix.
Steps to reproduce the issue:
- Create an image between 999,500,000 bytes and 1,000,000,000 bytes in size (mine was 999,517,084 bytes)
- Run
docker image ls - Note size is reported as
1e+03MB
Describe the results you received:
REPOSITORY TAG IMAGE ID CREATED SIZE
tmp-deb-full latest 5fbf6884916b 9 minutes ago 1e+03MB
Describe the results you expected:
REPOSITORY TAG IMAGE ID CREATED SIZE
tmp-deb-full latest 5fbf6884916b 9 minutes ago 1000MB
Additional information you deem important (e.g. issue happens only occasionally):
My Dockerfile that produced this result:
FROM debian:sid
COPY apt-sources.list /etc/apt/sources.list
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts cli-common-dev sbuild
I ran this on 2021-05-12 around 06:00 UTC. Reproducing the exact image I produced might be difficult since any new packages uploaded to Debian sid (whcih gets new packages uploaded all the time) would very likely have a different size and end up with a different image size, and I suspect the bug is triggered only when image size is >= 999.5MB and < 1000.0MB. Therefore, I preserved the image in question with docker image save. The .tar.xz file is 275 MB, so I won't attach it to this issue, but I can upload it somewhere and make it available on request, if anyone needs it. (Though I suspect one could repro this issue by creating an image full of zero bytes, so you may not need it.)
I've also included the output of docker image inspect below in case it helps.
Output of docker image inspect
[
{
"Id": "sha256:5fbf6884916b3cb9b4fd34e322553befe10df7ad285d217d06cd0dfe1754153e",
"RepoTags": [
"tmp-deb-full:latest"
],
"RepoDigests": [],
"Parent": "sha256:fa5df1ab58fe6d662ddefe3a92d9bb8a34f685e45de6ab1812ab37b880cc5a74",
"Comment": "",
"Created": "2021-05-12T05:50:53.620376318Z",
"Container": "ff4ab78243d481861dc73a740b8e3217b713dd603d5656a114139ba84f8992b4",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts cli-common-dev sbuild"
],
"Image": "sha256:fa5df1ab58fe6d662ddefe3a92d9bb8a34f685e45de6ab1812ab37b880cc5a74",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"DockerVersion": "20.10.2",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"bash"
],
"Image": "sha256:fa5df1ab58fe6d662ddefe3a92d9bb8a34f685e45de6ab1812ab37b880cc5a74",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 999517084,
"VirtualSize": 999517084,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/9074e34a9e7c1509ee5fe460707f6b18ed4398a484c359e716a7cd2e0c41d039/diff:/var/lib/docker/overlay2/fb68e8329c72acc7836a2a28400c387527f8ffad147962373dacb8052df2c13a/diff",
"MergedDir": "/var/lib/docker/overlay2/ef54d02d58c48a2d89cbe9d63026ca554177fe115690896e2c9731045159055b/merged",
"UpperDir": "/var/lib/docker/overlay2/ef54d02d58c48a2d89cbe9d63026ca554177fe115690896e2c9731045159055b/diff",
"WorkDir": "/var/lib/docker/overlay2/ef54d02d58c48a2d89cbe9d63026ca554177fe115690896e2c9731045159055b/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:ae0a22915636881ac7024d0fcf1d828d913a6cb0b243baa1d20fead12be078a7",
"sha256:2ab3f25d2804db9d2956cf35119c667aa794bce981ba0b590efe1291d7469e42",
"sha256:1adc272ccaf3b3dc95e69f351db9a509d0ea607df07c8cdc6e226ee95ae32210"
]
},
"Metadata": {
"LastTagTime": "2021-05-12T12:50:54.522154763+07:00"
}
}
]
Output of docker version:
Client:
Version: 20.10.2
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.2-0ubuntu1~18.04.2
Built: Tue Mar 30 21:24:16 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.2
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.2-0ubuntu1~18.04.2
Built: Mon Mar 29 19:27:41 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.3-0ubuntu1~18.04.4
GitCommit:
runc:
Version: spec: 1.0.2-dev
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:
Output of docker info:
Client:
Context: default
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 173
Server Version: 20.10.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version:
runc version:
init version:
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-72-generic
Operating System: Linux Mint 19.1
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 62.58GiB
Name: REDACTED
ID: REDACTED
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
localhost:32000
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
WARNING: No blkio weight support
WARNING: No blkio weight_device support
Additional environment details (AWS, VirtualBox, physical, etc.):