docker run [9] System error: exec format error

梦想的初衷 提交于 2020-08-06 08:08:08

问题


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


回答1:


Try to start bash before using your script, and use the --rm flag in order to destroy the instance once the job is ended, like that :

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



回答2:


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



来源:https://stackoverflow.com/questions/36544293/docker-run-9-system-error-exec-format-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!