这是我的 Dockerfile:
FROM debian
MAINTAINER Andrew Ford<andrew.ford@gg.com>
RUN apt-get update
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
这是我的 entrypoint.sh(与 Dockerfile 相同的目录)
#!/bin/bash
echo Hello
然后我跑了:
docker build --no-cache=true -t test/dockerfile-sayhello .
当我跑的时候:
docker run test/dockerfile-sayhello
它返回:
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Container command '/entrypoint.sh' not found or does not exist..
我试过用谷歌搜索看看我是否犯了任何明显的错误,但到目前为止我还无法识别它。也许你们中的一些人可以提供帮助
编辑:还运行 chmod +x entrypoint.sh 来授予权限
最佳答案
我刚刚尝试使用以下 Dockerfile(添加 chmod
)
FROM debian
MAINTAINER Andrew Ford<andrew.ford@gg.com>
RUN apt-get update
COPY entrypoint.sh /
RUN chmod 755 /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
它按预期工作。
它不像 issue 20789 :
I tried to transform a Dockerfile setup from phusion/baseimage to gliderslabs/alpine. Turns out that those shell scripts use
bash
-- of course! Simply change tosh
, asbash
is not present, resulting in the above error..
最新debian image应该包含 bash,因为它的默认值
CMD
是 /bin/bash
.
关于Docker Container Command 找不到 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38864037/