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:
I’ve tried changing several distro, like
Ubuntu (20.04/21.*/22.04)
rust:1.76-slim-buster -> both on the first and second stage (cause someone suggested that I have a glibc mismatch, because build for glibc Version A, but deploy the binary to Version C)
And using simplified dockerfile but still nothing.
I already tried the solution suggested in a question with the same error but still nothing for me…
2
Answers
The "buster" debian version is pretty old, and delivers a pretty old (2.28) glibc, which explains why you’d be missing the more modern glib symbols:
You can use a newer version of debian to get them, e.g., "bookworm":
To consume it, just replace the image name in the second
FROM
directive:one possible solution is to add this repo if you do not already have access to the package, as mentioned in the link:
then you should be able to install the missing package: