I have the tiniest of Docker Learn write-ups this week. 🙃
Alpine Builds and Runs so QUICKLY
Suppose you try each of the following commands:
docker run ubuntu
docker run fedora
docker run alpine
docker run golang
The first two commands install images and run super short-lived containers based on Ubuntu Linux and Fedora Linux, respectively. The third one does the same, but on Alpine Linux. By now I know that Alpine is 10x smaller than Ubuntu, but running these commands really brought the point home about why that makes a difference.
With the first two commands, it took a few seconds for the Docker daemon to download the images before it could run the container. But the third image (Alpine) downloaded so quickly that I almost didn't even notice the progress bar for it in the Docker terminal. The fourth command, on the other hand, took longer to execute than the first three combined.
docker images
= docker image ls
If I run docker images
or docker image ls
, both commands will output the same thing:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
golang latest 54e71dcafb7c 3 weeks ago 803MB
ubuntu latest 775349758637 3 weeks ago 64.2MB
fedora latest f0858ad3febd 3 weeks ago 194MB
alpine latest 965ea09ff2eb 4 weeks ago 5.55MB
This is a useful command, as I can now quickly compare the four images from above, by image size. The output seems to be sorted by image creation date rather than size. But it's still easy to compare the image sizes—and it's now obvious why the alpine
image downloaded so quickly and the golang
image so slowly, relatively speaking. Alpine was just 5.55 MB in size, compared to Golang's 803 MB.
By the way, docker images ls -a
will also output the same information. (I don't yet know under what conditions this would not be the case)
And that's it! Until next week 👋🏾.
Top comments (0)