Docker run [9] System error: exec format error

I created a Dockerfile to create 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 launch the image with the following command:

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

it works fine (the CMD command for start -aii.sh works by default). Now, if I try to override this default behavior and implicitly run the image with the same script (and add another argument), I get 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: script only (no argument)

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

and the full path to the script

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

but the same error appears.

Additional Information:

 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

+5
source share
2 answers

Try running bash before using the script and use the --rm flag to destroy the instance after the job completes:

 docker run -it --rm -v <some-volume-mapping> aii /bin/bash /usr/local/bin/start-aii.sh 
+3
source

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

+5
source

Source: https://habr.com/ru/post/1246856/


All Articles