/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found

Hello, I’m having a problem while running container. In my project there are 3 different containers (one for the backend, one for the frontend and one for mongodb), the last two works fine but the first (the one for the backend) gives me the following error:

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

And exit with status code: 1.This is the dockerfile

# Stage 1: Build the Rust app
FROM rust:1.76 as builder

WORKDIR /app

# Cache dependencies
COPY Cargo.toml Cargo.lock ./
RUN mkdir src
RUN echo "fn main() {}" > src/main.rs
RUN cargo build --release
RUN rm -rf src

# Copy source code and build the project
COPY . ./
RUN cargo build --release

# Stage 2: Create a lightweight image for the Rust app
FROM debian:buster-slim

RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl1.1 ca-certificates && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/backend /usr/local/bin/backend

EXPOSE 8080

CMD ["backend"]

and this is the docker-compose file

version: '3.8'

services:
  frontend:
    build:
      context: ./frontend
    ports:
      - "3000:80"
    depends_on:
      - backend

  backend:
    build:
      context: ./backend
    ports:
      - "8080:8080"
    environment:
      MONGO_URL: "mongodb://mongo:27017/wellness-tracker"
    depends_on:
      - mongo

  mongo:
    image: mongo:5.0
    volumes:
      - mongo-data:/data/db
    ports:
      - "27017:27017"

volumes:
  mongo-data:

It seems your rust builder image is building the application for different library version than your Debian running image provides.

Note that the Debian image “apt upgrade” is considered bad practice, as you will never be able to have a reproducible build. Next day build will always be different, as some libraries always change. So rather just use a stable latest Debian image.