GLIBC_2.38 Not Found: a Rust Binary in debian-slim and Distroless

My Axum binary built on rust:1 ran fine on bookworm-slim. Then I added vendored OpenSSL and it died before main with version GLIBC_2.38 not found. How to read the error, the objdump line that explains it, and three fixes I built and measured.

Simone Negro, Backend & AI Developer
11 min read

I set out to reproduce the classic Rust Docker failure: build stage on rust:1, runtime on debian:bookworm-slim, binary dies on start. It didn’t die. A plain Axum service built on Debian 13 ran happily on Debian 12. It only broke when I added one C dependency, vendored OpenSSL, and then it broke in exactly the way people search for:

hello-axum: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by hello-axum)

So the usual explanation, “your build image is newer than your runtime”, is close but not quite it. What matters is the newest glibc symbol your binary actually references. This post shows how to see that in one command, then three fixes I built and measured.

TL;DR

Build and run on the same Debian release, and pin it by codename so it can’t drift: FROM rust:1-trixie AS build with FROM gcr.io/distroless/cc-debian13 (or debian:trixie-slim). If you need to stay on Debian 12, build on rust:1-bookworm instead. To find out which symbol is the problem: objdump -T your-binary | grep -o 'GLIBC_[0-9.]*' | sort -uV | tail -3. If the runtime’s ldd --version is lower than the last line, it will fail.

Why rust:1 is the usual trigger right now

On Docker Hub today, the rust:1 and rust:latest tags point to Debian 13 (trixie). Bookworm is still there, but only under explicit tags like rust:1-bookworm. Plenty of Dockerfiles were written when rust:1 meant bookworm and pair it with debian:bookworm-slim or gcr.io/distroless/cc-debian12. Nobody touched those files. The base image moved under them.

I checked the glibc in each image with ldd --version (distroless has no shell, so for those I ran the libc.so.6 file directly, which prints its own version):

ImageDistroglibc
rust:1, rust:1-trixieDebian 13 trixie2.41
rust:1-bookwormDebian 12 bookworm2.36
debian:trixie-slimDebian 13 trixie2.41
debian:bookworm-slimDebian 12 bookworm2.36
debian:bullseye-slimDebian 11 bullseye2.31
gcr.io/distroless/cc-debian13Debian 13 trixie2.41
gcr.io/distroless/cc-debian12Debian 12 bookworm2.36
ubuntu:24.04Ubuntu 24.042.39
ubuntu:22.04Ubuntu 22.042.35

The raw lines look like this, from the build image and the runtime image of the broken setup:

$ docker run --rm rust:1 ldd --version | head -1
ldd (Debian GLIBC 2.41-12+deb13u5) 2.41
$ docker run --rm debian:bookworm-slim ldd --version | head -1
ldd (Debian GLIBC 2.36-9+deb12u14) 2.36

The Ubuntu rows matter because of where a lot of GLIBC_2.39 reports come from: a binary compiled on an Ubuntu 24.04 machine or devcontainer, then copied into a Debian 12 image. That is the case in distroless issue #1618. I didn’t reproduce 2.39 myself, but it is the same mechanism with a different number.

The setup

A small Axum 0.8 service, built in release mode with Rust 1.100.0. The /health handler builds a TLS client context with OpenSSL, the way an HTTP client using native-tls would. vendored compiles OpenSSL from source and links it statically, which is a common way to avoid needing libssl in the runtime image.

[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "net", "signal"] }
openssl = { version = "0.10", features = ["vendored"] }

[profile.release]
strip = true
use axum::{Router, routing::get};
use openssl::ssl::{SslConnector, SslMethod};

async fn health() -> String {
    // build a TLS client context, as an HTTP client with native-tls would
    let connector = SslConnector::builder(SslMethod::tls()).expect("tls context").build();
    drop(connector);
    format!("ok, {}\n", openssl::version::version())
}

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    let app = Router::new()
        .route("/", get(|| async { "hello\n" }))
        .route("/health", get(health));

    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
    println!("listening on {}", listener.local_addr()?);
    axum::serve(listener, app).await
}

The Dockerfile that breaks is the one you have probably seen a hundred times:

FROM rust:1 AS build
WORKDIR /src
COPY app/ .
RUN cargo build --release

FROM debian:bookworm-slim
COPY --from=build /src/target/release/hello-axum /usr/local/bin/hello-axum
CMD ["hello-axum"]

The build succeeds. The container starts and exits with code 1 before main runs:

$ docker run -d --name post5-run post5-broken
$ docker logs post5-run
hello-axum: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by hello-axum)
$ docker inspect -f "running={{.State.Running}} exit={{.State.ExitCode}}" post5-run
running=false exit=1

With gcr.io/distroless/cc-debian12 as the runtime the message is the same, only the path differs: /hello-axum: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /hello-axum).

That exit code 1 doesn’t come from your code. The dynamic loader prints the line and gives up before your program starts, so none of your logging runs. A restart policy will see a failing process. If you have read how a Rust binary’s exit code reaches Docker, note that none of it applies here, because main never runs.

What the error actually means

glibc versions its symbols. When the linker builds your binary, each function it imports from libc is tagged with the glibc version that introduced that exact symbol: memcpy@GLIBC_2.14, strtol@GLIBC_2.2.5, and so on. At startup the loader checks every tag against the libc present in the container. If the binary asks for a version that libc doesn’t have, it refuses to start and prints one line per missing version.

Two consequences. Glibc is backwards compatible, so a binary built against an old glibc runs on a newer one. And a binary built against a new glibc only fails on an old one if it uses a symbol that is newer than the old one. Being built on a newer system isn’t enough by itself.

Why the pure Rust build didn’t break

Before adding OpenSSL I built the same service without it, on the same rust:1, and ran it on bookworm-slim and cc-debian12. Both printed listening on 0.0.0.0:3000. This is what objdump reported for that binary, as the newest versions it requires:

$ objdump -T hello-axum | grep -o "GLIBC_[0-9.]*" | sort -uV | tail -5
GLIBC_2.29
GLIBC_2.30
GLIBC_2.32
GLIBC_2.33
GLIBC_2.34

The Rust standard library, Tokio and Axum only reached for symbols up to 2.34, and Debian 12 has 2.36. To check that the 2.34 wasn’t just luck, I ran the same binary on debian:bullseye-slim (glibc 2.31):

/hello-axum: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /hello-axum)
/hello-axum: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /hello-axum)
/hello-axum: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /hello-axum)

So if your search was for GLIBC_2.34 not found or GLIBC_2.32 not found, this is likely your case: a runtime on Debian 11 or similar, and a build stage on anything recent.

With vendored OpenSSL, the list grows by one line, and it’s the one that matters:

$ objdump -T hello-axum | grep -o "GLIBC_[0-9.]*" | sort -uV | tail -4
GLIBC_2.32
GLIBC_2.33
GLIBC_2.34
GLIBC_2.38
$ objdump -T hello-axum | grep -E "GLIBC_2\.(3[5-9]|4)"
0000000000000000      DF *UND*	0000000000000000 (GLIBC_2.38) __isoc23_strtol

__isoc23_strtol comes from a change in glibc 2.38: C23 lets strtol accept 0b binary prefixes, so glibc added new symbols for the new behaviour and redirects strtol calls to them when the code is compiled with C2X features on. _GNU_SOURCE turns those on, and plenty of C code defines it. OpenSSL’s C sources, compiled by openssl-src against trixie’s 2.41 headers, picked up the new symbol. Your Rust code didn’t change at all.

I tried the same thing with rusqlite and its bundled SQLite first, and that binary still topped out at 2.34. Which C dependency drags in a newer symbol depends on what functions it calls, so I wouldn’t try to memorise a list. Run the objdump line on your own binary.

Fix 1: build on the same Debian release you run on

The smallest change if you want to stay on Debian 12 is to pin the build stage to bookworm:

FROM rust:1-bookworm AS build
WORKDIR /src
COPY app/ .
RUN cargo build --release

FROM debian:bookworm-slim
COPY --from=build /src/target/release/hello-axum /usr/local/bin/hello-axum
CMD ["hello-axum"]

Built against 2.36 headers, the same OpenSSL code no longer asks for 2.38. The newest symbols are now GLIBC_2.33 and GLIBC_2.34, and the container answers:

listening on 0.0.0.0:3000
ok, OpenSSL 3.6.3 9 Jun 2026

The part that matters is the codename in both FROM lines. rust:1 with debian:bookworm-slim worked for a long time and then stopped, without anyone touching the Dockerfile, because only one side of the pair was pinned.

Fix 2: static musl, no glibc at all

If there is no glibc in the binary, there is no glibc version to mismatch. The x86_64-unknown-linux-musl target links everything statically, so the runtime can be scratch. Vendored OpenSSL needs a musl C compiler for this, hence musl-tools:

FROM rust:1 AS build
RUN apt-get update && apt-get install -y --no-install-recommends musl-tools && rustup target add x86_64-unknown-linux-musl
WORKDIR /src
COPY app/ .
RUN cargo build --release --target x86_64-unknown-linux-musl

FROM scratch
COPY --from=build /src/target/x86_64-unknown-linux-musl/release/hello-axum /hello-axum
CMD ["/hello-axum"]

file reports the result as ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, and objdump -T finds no GLIBC symbols at all. It ran and answered on /health like the others. The final image was the smallest of everything I built, under 10 MB.

There are two things to know before making it the default. scratch has no CA certificates, no /etc/passwd, no timezone data. If your service makes outbound TLS calls, use gcr.io/distroless/static-debian13 instead, which adds those for about 6.65 MB. The bigger one is the allocator. musl’s built-in malloc is known to be slow under multithreaded allocation, and an async server allocating on several Tokio worker threads is exactly that workload. Tweag’s write-up and a Rust forum thread both describe it, and the usual fix is setting mimalloc or jemalloc as the #[global_allocator]. I didn’t benchmark it for this post. A hello endpoint wouldn’t tell you much anyway, so measure your own service under load before you ship musl.

Fix 3: move the runtime to Debian 13

The other direction is to keep rust:1 and bring the runtime up to trixie. Distroless now defaults to Debian 13, and gcr.io/distroless/cc-debian13 exists for amd64 and arm64 among others. Its glibc is 2.41, the same as the build stage:

FROM rust:1-trixie AS build
WORKDIR /src
COPY app/ .
RUN cargo build --release

FROM gcr.io/distroless/cc-debian13
COPY --from=build /src/target/release/hello-axum /hello-axum
CMD ["/hello-axum"]

The binary still references GLIBC_2.38, which is fine, because 2.41 provides it. It started and answered ok, OpenSSL 3.6.3 9 Jun 2026. (In my measured run the build line was FROM rust:1, which today is the same image as rust:1-trixie. The pinned tag is what I’d commit.)

The numbers

All five variants ran on the same 12-core x86_64 Linux box. Each image was built three times with --no-cache, in a Docker 29.5.1 daemon with nothing else in its build cache, and I took the median. The host was shared with other jobs, so the build times are noisy. The broken pair ran first, while the machine was busiest, and the very same rust:1 → bookworm-slim build took 72.0, 67.8 and 52.1 s (median 67.8 s) when I rebuilt it at the end on a quieter host. Read the build column as “roughly a minute or two”, not as a ranking.

Sizes come from docker image ls --tree. Content is the compressed size of the image layers, which is roughly what a registry push or pull moves. Disk is the DISK USAGE column as that daemon reports it (containerd image store), which comes out larger than the unpacked size the older overlay2 store prints. Compare rows with each other, not with numbers from your own machine.

Build → runtimeRuntime glibcResultContentDiskBuild (median of 3)
rust:1 → debian:bookworm-slim2.36GLIBC_2.38' not found, exit 130.9 MB123 MB126.7 s
rust:1 → distroless/cc-debian122.36GLIBC_2.38' not found, exit 111.9 MB46.7 MB139.3 s
rust:1-bookworm → debian:bookworm-slim2.36runs30.9 MB123 MB94.0 s
rust:1 + musl → scratchnoneruns2.75 MB9.7 MB83.7 s
rust:1 → distroless/cc-debian132.41runs13.4 MB52.5 MB70.1 s

The binary itself is about 6.9 MB in every variant (6,873,832 bytes for the bookworm build, 6,899,488 for trixie, 6,950,792 for musl), so the differences between rows are almost entirely the base image.

Bonus: exec format error is a different bug

exec format error shows up in the same searches, but it has nothing to do with glibc. It means the binary was built for another CPU architecture. The typical case: the image was built on an Apple Silicon Mac, which produces linux/arm64 by default, and pushed to an amd64 server. The host I tested on is x86_64 with no arm64 emulation installed, so running any arm64 image reproduces it directly:

$ uname -m
x86_64
$ docker run --rm --platform linux/arm64 debian:bookworm-slim ldd --version
exec /usr/bin/ldd: exec format error

The fix is to build for the platform you deploy to: docker buildx build --platform linux/amd64 ..., or a multi-platform build if you deploy to both. In a Rust Dockerfile, the faster route is often to keep the build stage on the native platform with FROM --platform=$BUILDPLATFORM rust:1-trixie AS build and cross-compile with --target, instead of running the whole compiler under emulation. That route is a post of its own. The point here is how to tell the two errors apart: GLIBC_2.xx not found means right architecture, wrong libc, and exec format error means wrong architecture.

What I would put in a new Dockerfile

Pin both stages to the same Debian codename and pick the newest release you can run: rust:1-trixie with gcr.io/distroless/cc-debian13. It handled the C dependency without any changes, the image was about 13 MB compressed, and nothing in it depends on what rust:1 happens to mean next year. Debian 14 will arrive one day, rust:1 will follow it, and an unpinned runtime will break again with a new number in the same error.

I’d only reach for musl and scratch when image size really matters, and only after load-testing the allocator change. Distroless with the same glibc on both sides is the boring option, and with glibc boring is what I want. If you want the full runtime picture for the same kind of service, the graceful shutdown with SIGTERM in Docker post covers what happens when the container is stopped, after it has managed to start.

References