关于 docker alpine 镜像

文章目录

    alpine 这个单词真的很难记住,每次都记不住。

    单独的“alpine”可以翻译为“高山的;阿尔卑斯山的;阿尔卑斯山区居民的”等,也可直接翻译为“阿尔卑斯山”或“高山”。其官网首页也确实是一张雪山的照片,是不是阿尔卑斯山就不知道了。发音是,阿尔派恩😊

    docker alpine 镜像有多小

    > docker.exe images
    REPOSITORY                              TAG          IMAGE ID       CREATED        SIZE
    test                                    latest       b25393d9067c   4 hours ago    26.8MB
    m.daocloud.io/docker.io/alpine          3.20.3       91ef0af61f39   3 weeks ago    7.8MB
    m.daocloud.io/docker.io/php             8.2-fpm      9b2142f48ee3   2 months ago   494MB
    m.daocloud.io/docker.io/mysql           8.0          23b013c7c67d   2 months ago   572MB
    nginx                                   latest       a72860cb95fd   3 months ago   188MB
    

    可以看到:

    • alpine 镜像只有 7.8M
    • 而 golang 程序打包进 alpine, 整个镜像大小为 26.8M。这个 golang 程序大概 18/19M 大小。

    官方的描述

    Alpine Linux is built around musl libc and busybox. This makes it small and very resource efficient. A container requires no more than 8 MB and a minimal installation to disk requires around 130 MB of storage. Not only do you get a fully-fledged Linux environment but a large selection of packages from the repository.

    alpine 最新版本号

    https://hub.docker.com/_/alpine

    3.20.3

    我感觉在设置 Dockerfile 或者 docker-compose 文件时,指定镜像版本号是比较理性的做法。
    而指定 latest 最新版本,你永远不知道会不会带来大坑。

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式