0

A simple Dockerfile that executes a shell script as entrypoint like this

FROM python:3
WORKDIR /app

COPY . .
RUN chmod +x entrypoint.sh
CMD ["python", "/app/src/api.py"]
ENTRYPOINT ["./entrypoint.sh"]

works: entrypoint.sh is called, which itself executes python /app/src/api.py on a RPI 3.

entrypoint.sh

#!/bin/bash
echo starting entrypoint
set -x
exec "$@"

Since I don't need anything Debian/Raspbian specific, I'd like to use the alpine image to reduce image size. So I changed FROM python:3 to FROM python:3-alpine without any further changes.

But now the container doesn't start:

api_1      | standard_init_linux.go:211: exec user process caused "no such file or directory"
test_api_1 exited with code 1

Why doesn't this work on Alpine? I don't see any problem since /app/entrypoint.sh exists and it's also executable:

Step 5/7 : RUN ls -lh
 ---> Running in d517a83c5b9b
total 12K    
-rwxr-xr-x    1 root     root          54 Jul 11 18:35 entrypoint.sh
drwxr-xr-x    2 root     root        4.0K Jul 11 18:48 src

In a similar question, the image was buld on a non-arm system. This is not the case for me, I'm building directly on the RPI.

Not sure if this is Raspbian or Alpine related. I also tried using the absolute path ENTRYPOINT ["/app/entrypoint.sh"]: Still working on python:3 image, but broken in python:3-alpine.

Lion
  • 16,606
  • 23
  • 86
  • 148

1 Answers1

2

The problem was that my entrypoint uses bash as shebang without thinking about it:

#!/bin/bash
echo starting entrypoint
set -x
exec "$@"

But alpine doesn't include GNU Bash, which is installed on Debian/Raspbian by default. The no such file or directory was specified to the interpreter from the shebang, not the entrypoint script itself.

Since my script is not indent to make something that requires bash features, I just changed #!/bin/bash to #!/bin/sh and it could be also started on the alpine image.

Lion
  • 16,606
  • 23
  • 86
  • 148
  • If you answer your own question, you could at least put the information need to identity the error (the shebang) into the question. – Klaus D. Jul 11 '20 at 19:13
  • @KlausD. Thank you for the suggestion, I added the entrypoint script in the question, too, – Lion Jul 12 '20 at 08:47