Home > front end >  Alpine docker image __isnan: symbol not found
Alpine docker image __isnan: symbol not found

Time:10-11

Here's the Dockerfile I am using to build a Golang application and a worker

FROM golang:1.15 AS build

RUN mkdir -p /go/api/proj

WORKDIR /go/api/proj

COPY go.* ./

RUN go mod download

COPY . .

RUN go mod tidy

RUN go build -o proj ./api/

RUN go build -o worker ./worker/

FROM alpine:3.14

WORKDIR /

RUN apk add libc6-compat cmake

RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

COPY . .

COPY --from=build /go/api/proj/proj .

COPY --from=build /go/api/proj/worker .

EXPOSE 80

CMD ["./worker"]

I had to add libc6-compat because kafka setup in worker wasn't compatible with musl library of alpine

Here's the error I received when trying to run worker in docker container

Error relocating ./worker: __strdup: symbol not found
Error relocating ./worker: __isnan: symbol not found
Error relocating ./worker: __strndup: symbol not found

Can someone suggest what's going wrong here and solution for it?

I am using confluent kafka in worker which may be the reason for this error.

CodePudding user response:

Can someone suggest what's going wrong here and solution for it?

What you are doing here:

RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

is pretending that Musl is GLIBC. It isn't, and that doesn't work.

From Musl FAQ:

Binary compatibility is much more limited, but it will steadily increase with new versions of musl. At present, some glibc-linked shared libraries can be loaded with musl, but all but the simplest glibc-linked applications will fail if musl is dropped-in in place of /lib/ld-linux.so.2.

Instead of building the worker binary against GLIBC and then trying to run it with Musl, you should build it against Musl.

  • Related