-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: "Docker image size" | ||
date: 2024-12-05T13:05:44+01:00 | ||
tags: | ||
- dev | ||
- devops | ||
--- | ||
|
||
When trying to optimize docker images in terms of size, the workflow is as | ||
follows: | ||
|
||
<!--more--> | ||
|
||
## Terminal 1 | ||
|
||
```shell | ||
% docker build -f Dockerfile . -t argocd-download-tools | ||
``` | ||
|
||
...possibly paired up with `entr` or `fswatch` depending on your eagerness for | ||
automatic builds. | ||
|
||
## Terminal 2 | ||
|
||
```shell | ||
% docker image inspect argocd-download-tools | jq -r '.[0].Size' | numfmt --to=iec | ||
134M | ||
``` | ||
|
||
...possibly prepended with `watch`. | ||
|
||
I wasn't aware of [`numfmt`](https://man.archlinux.org/man/numfmt.1): | ||
|
||
> numfmt - Convert numbers from/to human-readable strings | ||
...instead of displaying plain bytes, it converts numbers to human-readable | ||
strings (à la `df -h` or `free -h`). | ||
|
||
Regarding the [units](https://en.wikipedia.org/wiki/Binary_prefix): they don't | ||
matter much, because we are only interested in an approximation, no need to | ||
shave bytes off here. `SI` has 1k = 1000, whereas `IEC` has 1Ki = 1024. |