本文介绍了为什么我的 docker-entrypoint.sh 不执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 ENTRYPOINT 脚本没有执行并抛出 standard_init_linux.go:175: exec 用户进程导致没有这样的文件或目录".为什么会这样?

My ENTRYPOINT script doesn't execute and throws standard_init_linux.go:175: exec user process caused "no such file or directory". Why so?

$ docker build -t gilani/trollo . && docker run gilani/trollo
Sending build context to Docker daemon   126 kB
Step 1 : FROM vault:latest
 ---> 1f127f53f8b5
Step 2 : MAINTAINER Amin Shah Gilani <[email protected]>
 ---> Using cache
 ---> 86b885ca1c81
Step 3 : COPY vaultConfig.json /vault/config
 ---> Using cache
 ---> 1a2be2fa3acd
Step 4 : COPY ./docker-entrypoint.sh /
 ---> Using cache
 ---> 0eb7c1c992f1
Step 5 : RUN chmod +x /docker-entrypoint.sh
 ---> Running in 251395c4790f
 ---> 46aa0fbc9637
Removing intermediate container 251395c4790f
Step 6 : ENTRYPOINT /docker-entrypoint.sh
 ---> Running in 7434f052178f
 ---> eca040859bfe
Removing intermediate container 7434f052178f
Successfully built eca040859bfe
standard_init_linux.go:175: exec user process caused "no such file or directory"

Dockerfile:

Dockerfile:

FROM vault:latest

MAINTAINER Amin Shah Gilani <[email protected]>

COPY vaultConfig.json /vault/config

COPY ./docker-entrypoint.sh /

RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]

docker-entrypoint.sh:

docker-entrypoint.sh:

#!/bin/bash

echo 'Hello World!'

作品

$ docker build -t gilani/trollo . && docker run gilani/trollo
Sending build context to Docker daemon   126 kB
Step 1 : FROM vault:latest
 ---> 1f127f53f8b5
Step 2 : MAINTAINER Amin Shah Gilani <[email protected]>
 ---> Using cache
 ---> 86b885ca1c81
Step 3 : COPY vaultConfig.json /vault/config
 ---> Using cache
 ---> 1a2be2fa3acd
Step 4 : ENTRYPOINT echo 'hello world'
 ---> Using cache
 ---> ef5792a1f252
Successfully built ef5792a1f252
'hello world'

Dockerfile:

Dockerfile:

FROM vault:latest

MAINTAINER Amin Shah Gilani <[email protected]>

COPY vaultConfig.json /vault/config

ENTRYPOINT ["echo", "'hello world'"]

推荐答案

vault:latest 图像不包含您尝试调用的 /bin/bashshebang #!/bin/bash.您应该将其更改为 #!/bin/sh 或从脚本中完全删除 shebang.

the vault:latest image does not contain /bin/bash which you try to call with your shebang #!/bin/bash. You should either change that to #!/bin/sh or completely remove the shebang from your script.

这篇关于为什么我的 docker-entrypoint.sh 不执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 18:20