For example, you want to execute the following shell script.
# /usr/local/bin/run.sh
echo "hello, world"
Dockerfile
ADD run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/run.sh
CMD ["/usr/local/bin/run.sh"]
When you run the container, your expectation is the container prints out hello, world. However, what you will get is a error message:
$ docker run -i hello_world_image
You see this message when you didn’t put shebang in your script, and because of that, default entry point /bin/sh -c does not know how to run the script.
To fix this, you can either add shebang
/usr/local/bin/run.sh
#!/bin/bash
echo "hello, world"
or you can specify from command line.
$ docker run -entrypoint="/bin/bash" -i hello_world_image
==========================================================================