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.
one possible solution is to add this repo if you do not already have access to the package, as mentioned in the link:
You should be able to use any of the listed mirrors by adding a line to your /etc/apt/sources.list like this:
deb http://security.ubuntu.com/ubuntu jammy-security main
then you should be able to install the missing package:
sudo apt update
sudo apt install libc6
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:
$ docker run -it debian:buster-slim /usr/bin/ldd --version
ldd (Debian GLIBC 2.28-10+deb10u3) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
You can use a newer version of debian to get them, e.g., "bookworm":
$ docker run -it debian:bookworm-slim /usr/bin/ldd --version
ldd (Debian GLIBC 2.36-9+deb12u7) 2.36
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
To consume it, just replace the image name in the second FROM directive:
# Stage 2: Create a lightweight image for the Rust app
FROM debian:bookworm-slim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With