1

I have an application I'm creating a docker image for, the image is created but when I run it the container errors saying it cannot find the executable file.

Here is my docker file:

FROM alpine:3.14
WORKDIR /
EXPOSE 3000
COPY ./weather-api /weather-api
CMD ["/weather-api"]

I've included a RUN ls -la immediately above the CMD which shows the file is there whilst building the image is being built, and I've included a shell script with la -la as the CMD which has shows that the files is there when the image is being ran.

This is the error I'm getting:

standard_init_linux.go:228: exec user process caused: no such file or directory

When I try to call the weather-api from a shell script I get the standard file not found error.

I've tried using an absolute and relative path for the command, copying the file to /usr/local/bin which I think should put it on the PATH so it would be callable from anywhere, changing COPY to ADD.

I'm still new to docker so any help would be greatly appreciated.

valiano
  • 16,433
  • 7
  • 64
  • 79
Stiv
  • 153
  • 2
  • 9
  • Is "apline" a typo or is it really apline? – M. Zhang Jul 04 '21 at 12:22
  • 2
    And as alpine is based on musl libc, if your program is compiled to link to glibc or other dynamic libraries, it will also error out with "no such file or directory". – M. Zhang Jul 04 '21 at 12:25
  • What is weather-api? How was it created? – BMitch Jul 04 '21 at 12:57
  • Sorry apline is a typo, its correct in the dockerfile – Stiv Jul 04 '21 at 13:01
  • weather-api is the application I'm trying to run in docker, its a web api written in rust and cross compiled for armv7 to run on a raspberry pi, the errors I'm getting are when trying to build and run the docker image on a raspberry pi. – Stiv Jul 04 '21 at 13:04
  • @M.Zhang the program does link to some dynamic libraries so I've tried changing from alpine to ubuntu;xenial and its now working. Thanks – Stiv Jul 04 '21 at 13:13
  • 2
    `file not found` error on Alpine Linux, when the file is actually present, is typical symptom of a dynamic linking error when trying to run binaries that were built on non Alpine distros (e.g. Ubuntu, Debian). See: https://stackoverflow.com/questions/66963068/docker-alpine-executable-binary-not-found-even-if-in-path/66974607 – valiano Oct 01 '21 at 19:46
  • If you can, build the binary using an alpine container (checkout docker multi-stage builds), then you should have no problem running it on alpine as it will be compiled against the alpine SO's rather than the GNU SO's. Even better if you do the build on your rpi too, then you won't need to cross-complie. – Software Engineer Oct 01 '21 at 20:26

0 Answers0