4

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
Azamat Abdullaev
  • 726
  • 9
  • 24
  • Can you include your image's Dockerfile? Are you correctly copying the PNG file you attached into the image; `COPY j27cg.png .`? Where does the `makeThumb` binary come from, and how is this PNG file related to it? – David Maze May 24 '21 at 12:56
  • @DavidMaze Included the Dockerfile. This PNG file `j27cg.png` does not relate to the Docker image in any way. It is just a screenshot – Azamat Abdullaev May 24 '21 at 13:01
  • Could be that the `makeThumb` program is compiled to target another architecture than the one you are using. Can you post the result from `file makeThumb` and `uname -a` ? – ShellCode May 24 '21 at 13:02
  • Can you post the output of `ldd makeThumb` ? It could be a missing dependency. EDIT: actually, don't post it, just make sure all the dependencies are met ;) – ShellCode May 24 '21 at 13:07
  • That Dockerfile doesn't obviously produce or run a binary named `makeThumb`. – David Maze May 24 '21 at 13:08
  • @DavidMaze Yes, the Dockerfile does not run it itself. The Nodejs application deployed in this image invokes this executable. – Azamat Abdullaev May 24 '21 at 13:11
  • @ShellCode I have run `ldd`, at the output has something like this: `Error relocating makeThumb: __strdup: symbol not found` – Azamat Abdullaev May 24 '21 at 13:15
  • That sounds like it would be useful to add in full to the question itself. The line(s) before it probably reveal which library is missing. – tripleee May 24 '21 at 13:18
  • 1
    See: https://stackoverflow.com/questions/66963068/docker-alpine-executable-binary-not-found-even-if-in-path/ – valiano May 26 '21 at 03:30

1 Answers1

2

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 :

  • Try to install glibc in your docker container
  • Probably the easiest solution : try to find a Docker image that uses it as default (a minimalistic Debian/Ubuntu Docker should do it)
ShellCode
  • 1,072
  • 8
  • 17