Skip to content

Commit cad8ad1

Browse files
authored
Merge pull request #2504 from MikeMcC399/alpine-description
docs: update Alpine size and musl description
2 parents b227a67 + 2e25e02 commit cad8ad1

1 file changed

Lines changed: 26 additions & 31 deletions

File tree

README.md

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -182,37 +182,32 @@ Active Long Term Support version of Node.js. See also [Long Term Support](#long-
182182

183183
### `node:alpine`
184184

185-
This image is based on the popular
186-
[Alpine Linux project](https://alpinelinux.org), available in
187-
[the `alpine` official image](https://hub.docker.com/_/alpine). Alpine Linux is
188-
much smaller than most distribution base images (~5MB), and thus leads to much
189-
slimmer images in general.
190-
191-
This variant is highly recommended when final image size being as small as
192-
possible is desired. The main caveat to note is that it does use
193-
[musl libc](https://musl.libc.org/) instead of
194-
[glibc and friends](https://www.etalabs.net/compare_libcs.html), so certain
195-
software might run into issues depending on the depth of their libc
196-
requirements. However, most software doesn't have an issue with this, so this
197-
variant is usually a very safe choice. See
198-
[this Hacker News comment thread](https://news.ycombinator.com/item?id=10782897)
199-
for more discussion of the issues that might arise and some pro/con comparisons
200-
of using Alpine-based images.
201-
202-
One common issue that may arise is a missing shared library required for use of
203-
`process.dlopen`. To add the missing shared libraries to your image:
204-
205-
- Starting from Alpine v3.19, you can use the
206-
[`gcompat`](https://pkgs.alpinelinux.org/package/v3.19/main/x86/gcompat) package
207-
to add the missing shared libraries: `apk add --no-cache gcompat`
208-
209-
To minimize image size, it's uncommon for additional related tools
210-
(such as `git` or `bash`) to be included in Alpine-based images. Using this
211-
image as a base, add the things you need in your own Dockerfile
212-
(see the [`alpine` image description](https://hub.docker.com/_/alpine/) for
213-
examples of how to install packages if you are unfamiliar).
214-
215-
To make the image size even smaller, you can [bundle without npm/yarn](./docs/BestPractices.md#smaller-images-without-npmyarn).
185+
This image is based on
186+
[Alpine Linux](https://alpinelinux.org). Because base
187+
[alpine](https://hub.docker.com/_/alpine) images are smaller
188+
than corresponding base
189+
[debian](https://hub.docker.com/_/debian) images, the resulting
190+
`node:alpine` Docker images are around 25% smaller than the
191+
Debian-based `node:slim` images.
192+
193+
Alpine images use the C library
194+
[musl libc](https://musl.libc.org/), not the GNU C library
195+
[glibc](https://sourceware.org/glibc/) used by Debian.
196+
197+
Generally, applications written for Debian (`glibc`) will not run under Alpine (`musl`).
198+
Some compatibility issues may be resolvable by installing the Alpine
199+
[`gcompat`](https://pkgs.alpinelinux.org/package/v3.23/main/x86/gcompat)
200+
GNU C Library compatibility layer for musl package.
201+
Use `apk add --no-cache gcompat` to install.
202+
203+
Tools such as `git` or `bash` are not included in `node:alpine*` based images. The
204+
[Alpine documentation](https://docs.alpinelinux.org/) describes how to find and
205+
install additional packages using `apk` (Alpine Package Keeper).
206+
207+
The
208+
[Best Practices document](./docs/BestPractices.md), in the section
209+
[Smaller images without npm/yarn](./docs/BestPractices.md#smaller-images-without-npmyarn),
210+
shows how to produce a custom image by removing package managers in a multi-stage build.
216211

217212
### `node:bullseye`
218213

0 commit comments

Comments
 (0)