The official Docker image for Why
Docker images today are big.
Usually much larger than they need to be.
There are a lot of ways to make them smaller, but the Docker populace still jumps to the ubuntu base image for most projects.
The size savings over ubuntu and other bases are huge:
REPOSITORY TAG IMAGE ID CREATED SIZE alpine latest 961769676411 4 weeks ago 5.58MB ubuntu latest 2ca708c1c9cc 2 days ago 64.2MB debian latest c2c03a296d23 9 days ago 114MB centos latest 67fa590cfc1c 4 weeks ago 202MB
There are images such as progrium/busybox which get us close to a minimal container and package system, but these particular BusyBox builds piggyback on the OpenWRT package index, which is often lacking and not tailored towards generic everyday applications.
Alpine Linux has a much more featureful and up to date $ docker run progrium/busybox opkg-install nodejs
Unknown package 'nodejs'.
Collected errors:
* opkg_install_cmd: Cannot install package nodejs.
$ docker run alpine apk add --no-cache nodejs
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/7) Installing ca-certificates (20190108-r0)
(2/7) Installing c-ares (1.15.0-r0)
(3/7) Installing libgcc (8.3.0-r0)
(4/7) Installing http-parser (2.8.1-r0)
(5/7) Installing libstdc++ (8.3.0-r0)
(6/7) Installing libuv (1.23.2-r0)
(7/7) Installing nodejs (10.14.2-r0)
Executing busybox-1.29.3-r10.trigger
Executing ca-certificates-20190108-r0.trigger
OK: 31 MiB in 21 packages
This makes Alpine Linux a great image base for utilities, as well as production applications.
Stop doing this:
FROM ubuntu:22.04 RUN apt-get update -q \ && DEBIAN_FRONTEND=noninteractive apt-get install -qy mysql-client \ && apt-get clean \ && rm -rf /var/lib/apt ENTRYPOINT ["mysql"]
This took 28 seconds to build and yields a 169 MB image. Start doing this:
FROM alpine:3.16 RUN apk add --no-cache mysql-client ENTRYPOINT ["mysql"]
Only 4 seconds to build and results in a 41 MB image!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。