Skip to content

Commit

Permalink
new post: docker image size
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagowfx committed Dec 5, 2024
1 parent cd5575d commit 6095ea6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions content/posts/2024-12-05-docker-image-size.md
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.

0 comments on commit 6095ea6

Please sign in to comment.