Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to fix docker: exec format error  (Read 5242 times)

0 Members and 1 Guest are viewing this topic.

joseletk

  • Guest
How to fix docker: exec format error
« on: June 16, 2018, 10:53:00 am »
For example, you want to execute the following shell script.

Code: [Select]
# /usr/local/bin/run.sh

echo "hello, world"

Dockerfile

Code: [Select]
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

Code: [Select]
#!/bin/bash
echo "hello, world"

or you can specify from command line.

Code: [Select]
$ docker run -entrypoint="/bin/bash" -i hello_world_image==========================================================================
« Last Edit: June 19, 2018, 02:09:50 pm by manoj »