Image size reported as 1e+03MB by `docker image ls`
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.):
Still occurs with Docker 20.10.8, running on Ubuntu 21.10.
Output of docker version on my Ubuntu 21.10 test VM:
Client: Docker Engine - Community
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:53:57 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:52:06 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Output of docker info on my Ubuntu 21.10 test VM:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.6.1-docker)
scan: Docker Scan (Docker Inc., v0.8.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 2
Server Version: 20.10.8
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
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: e25210fe30a0a703442421b0f60afac609f950a3
runc version: v1.0.1-0-g4144b63
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.11.0-20-generic
Operating System: Ubuntu Impish Indri (development branch)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 971.7MiB
Name: ubuntu-impish
ID: FOPY:SQMP:IOHW:CLZA:IAM2:IVWA:E5IY:AHE6:OVHF:LOZO:2CPL:PHGN
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
I second this, not a big deal but looks weird.
➜ docker --version
Docker version 20.10.17, build 100c701
➜ uname -a
Linux blackstar 5.4.0-107-generic #121-Ubuntu SMP Thu Mar 24 16:04:27 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
➜ git:(master) docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nvidia/nvidia-driver-flatcar 470.103.01 0931e1f8d96c 50 minutes ago 1e+03MB
Just saw this on my Manjaro Linux machine:
Docker version 23.0.1, build a5ee5b1dfc
Client:
Version: 23.0.1
API version: 1.42
Go version: go1.20
Git commit: a5ee5b1dfc
Built: Sat Feb 11 13:58:04 2023
OS/Arch: linux/amd64
Context: default
Server:
Engine:
Version: 23.0.1
API version: 1.42 (minimum version 1.12)
Go version: go1.20
Git commit: bc3805a0a0
Built: Sat Feb 11 13:58:04 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.6.16
GitCommit: 31aa4358a36870b21a992d3ad2bef29e1d693bec.m
runc:
Version: 1.1.4
GitCommit:
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Hi, I'd like to give this a go. I already made a sample image to reproduce it and I'm setting up the environment
I hope fixing this issue on docker go-units fixes this.
Hi, I'm from the UT Austin virtualization class, and as part of our open-source project, I'd like to take on this issue if possible. Given that it is labeled as a beginner issue, it would fit into my current open-source contribution experience. Thanks!