I have Dockerfile containing:
FROM alpine
COPY script.sh /script.sh
CMD ["./script.sh"]
and a script.sh
(with executable permission):
#!/bin/bash
echo "hello world from script file"
when I run
docker run --name testing fff0e5c81ca0
where fff0e5c81ca0 is the id after building, I get an error
standard_init_linux.go:195: exec user process caused "no such file or directory"
So how can I solve it?
By default, bash is not included with BusyBox and Alpine Linux. The postmarketOS project, which is designed to run on mobile devices, is based on Alpine Linux. Many Docker images are also based upon Alpine, and you may install bash shell in Docker-based images too.
There is no Bash installed by default; Alpine uses BusyBox Bash as the default shell.
Note: By default Alpine Linux uses the ash shell, but many users may prefer bash, zsh, fish or another shell.
To run a bash script in alpine based image, you need to do either one
Install bash
$ RUN apk add --update bash
Use #!/bin/sh
in script instead of #!/bin/bash
You need to do any one of these two or both
Or, like @Maroun's answer in comment, you can change your CMD to execute your bash script
CMD ["sh", "./script.sh"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With