dockerdocker-container

File not found in docker container


I'm doing something extremely simple. Here is my Dockerfile:

FROM alpine:latest

ADD hello.sh /bin/hello
RUN chmod +x /bin/hello

CMD /bin/hello

Then I build the image:

docker build -t hello .

Then I run the image:

docker run hello

And here is the output:

/bin/sh: /bin/hello: not found

Why is this happening? If I run:

docker run hello cat /bin/hello

I can see the content of my script, which makes me even more confused.


Solution

  • Problem solved by using an ubuntu image instead of an alpine image. Not exactly sure why, but might have to do with the file's user/permission bits getting copied over and not interpreted correctly.