Here is the output of my terminal, while I am inside the shell of a Docker container with an Alpine image:
bash-5.0# ls
makeThumb
bash-5.0# ./makeThumb
bash: ./makeThumb: No such file or directory
bash-5.0#
As you can see, I have an executable file called makeThumb
, and it is definitely there (see the output of ls
). However, it is strange that when I'm trying to execute it with ./makeThumb
it says No such file or directory
.
How to solve this?
My Dockerfile:
FROM mhart/alpine-node:14 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
FROM mhart/alpine-node:14
RUN apk update && apk add bash
COPY --from=build /app/ /app/
WORKDIR /app
RUN npm prune --production
EXPOSE 3000
CMD [ "node", "server.js" ]
Output of ldd makeThumb
:
ldd makeThumb
/lib64/ld-linux-x86-64.so.2 (0x7f0c421ae000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f0c421ae000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f0c421ae000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7f0c421ae000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f0c42015000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0c421ae000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f0c42001000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0c421ae000)
Error relocating makeThumb: __strdup: symbol not found
Error relocating makeThumb: __vfprintf_chk: symbol not found
Error relocating makeThumb: __sprintf_chk: symbol not found
Error relocating makeThumb: __snprintf_chk: symbol not found
Error relocating makeThumb: __vsnprintf_chk: symbol not found
Error relocating makeThumb: __strcat_chk: symbol not found
Error relocating makeThumb: __memset_chk: symbol not found
Error relocating makeThumb: __fprintf_chk: symbol not found
Error relocating makeThumb: __memcpy_chk: symbol not found
Error relocating makeThumb: __longjmp_chk: symbol not found
Alpine makes use of musl which is a minimalistic libc. My guess is that your binary is using non-standard functions that do not exist under Alpine.
I see two solutions to that :