0

Screenshot of the existing file and that alpine says that the file could not be found

I have an Alpine container that I copy a binary to (in this case it is spar). The entry point is dumb-init /usr/bin/spar but it results in a No such file or directory. When I run sh inside of the container, /usr/bin/spar exists. Trying to run it in

  1. dumb-init ...
  2. /usr/bin/spar / spar from /
  3. ./spar / spar from usr/bin/

All result in the same error. I tried changing the permissions with chmod 777 /usr/bin/spar giving everyone full access, still no luck.

Am I missing something that is specific to alpine? In another SO issue someone mentioned that switching from Alpine to Ubuntu solved their issue, but no further info was provided.

Here is the dockerfile that creates the image(s)

ARG intermediate=quay.io/wire/alpine-intermediate
ARG deps=quay.io/wire/alpine-deps

#--- Intermediate stage ---
FROM ${intermediate} as intermediate

#--- Minified stage ---
FROM ${deps}

ARG executable
ENV CACHEDEXECUTABLE ${executable}

COPY --from=intermediate /dist/${executable} /usr/bin/${executable}

# TODO: only if executable=brig, also copy templates. Docker image conditionals seem hacky:
# https://stackoverflow.com/questions/31528384/conditional-copy-add-in-dockerfile
# For now, adds ~2 MB of additional files into every container
COPY --from=intermediate /dist/templates/ /usr/share/wire/templates/

# ARGs are not available at runtime, create symlink at build time
# more info: https://stackoverflow.com/questions/40902445/using-variable-interpolation-in-string-in-docker
RUN ln -s /usr/bin/${executable} /usr/bin/service
ENTRYPOINT /usr/bin/dumb-init /usr/bin/${CACHEDEXECUTABLE}

Twiggeh
  • 1,030
  • 1
  • 12
  • 24
  • Can you provide a [mcve]? If it's a dynamically-linked binary, you can get that message if shared libraries or the loader don't exist; if it's a script, you can also get that error if the script interpreter isn't available or if the script incorrectly has DOS line endings. – David Maze Aug 03 '21 at 13:13
  • What image are you running? Do you have the Dockerfile to show? Do you map any volumes on the /usr/bin path when you run the container? – Hans Kilian Aug 03 '21 at 13:14
  • @DavidMaze spar is a copy-pasted binary, it exists in the directory, but when I try to run it says that it doesn't exist, when I try to cat it, I get an output of binary data. (Reproducible will be difficult, because of the amount of steps needed to get to this point) – Twiggeh Aug 03 '21 at 14:58
  • @HansKilian I have added the dockerfile, I can also upload the image if that would help. I don't think I am mapping any volumes – Twiggeh Aug 03 '21 at 15:04

1 Answers1

3

If spar is a binary, that binary exists in the container, and you call it directly or it's in the containers path, then the two likely reasons for a file not found are:

  1. Dynamically linked libraries that don't exist inside the container. E.g. of you run ldd spar it will show you those links, and there's a good chance you'll see libc despite trying to run on Alpine where it uses musl.

  2. The binary is for another platform/architecture, and you have binfmt_misc setup, but without the --fix-binary option so it's looking for the interpreter path in the container filesystem rather than the host. This will be visible by the lack of an F flag in the /proc file for that platform.

BMitch
  • 231,797
  • 42
  • 475
  • 450