Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker run [9] System error: exec format error

I created Dockerfile to build my image called aii.

FROM docker.io/centos:latest

#Set parameters
ENV BinDir /usr/local/bin
ENV RunFile start-aii.sh

ADD ${RunFile} ${BinDir}
#Some other stuff
...

CMD ${RunFile}

When I run the image with the following command:

docker run -it -v <some-volume-mapping> aii

it's works great (default operation of running CMD command of start-aii.sh). Now, if I try to override this default behavior and to run the image with the same script implicitly (and add another arg) I'm getting the following error:

docker run -it -v <some-volume-mapping> aii start-aii.sh kafka
exec format error
docker: Error response from daemon: Cannot start container b3f4f3bde04d862eb8bc619ea55b7061ce78ace8f1984a12f6ec681877d7d926: [9] System error: exec format error.

I also tried: only script (without argument)

docker run -it -v <some-volume-mapping> aii start-aii.sh

and full path to script

docker run -it -v <some-volume-mapping> aii /usr/local/bin/start-aii.sh

but the same error appear.

Another info:

docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
2488a4dd7014        aii                 "start-aii.sh kafka"     3 seconds ago       Created                                 tiny_payne

Any suggestions?

Thanks

like image 829
ItayB Avatar asked Apr 11 '16 09:04

ItayB


1 Answers

Had the same issue, fixed it by adding #!/bin/sh at the top of the file instead of having other comments.

like image 154
Flavio Troia Avatar answered Sep 21 '22 12:09

Flavio Troia