我在Docker上遇到了麻烦。
这是我的DockerFile
FROM alpine:3.3
WORKDIR /
COPY myinit.sh /myinit.sh
ENTRYPOINT ["/myinit.sh"]
myinit.sh
#!/bin/bash
set -e
echo 123
那就是我建立形象的方式
docker build -t test --no-cache
运行日志
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM alpine:3.3
---> d7a513a663c1
Step 2 : WORKDIR /
---> Running in eda8d25fe880
---> 1dcad4f11062
Removing intermediate container eda8d25fe880
Step 3 : COPY myinit.sh /myinit.sh
---> 49234cc3903a
Removing intermediate container ffe6227c921f
Step 4 : ENTRYPOINT /myinit.sh
---> Running in 56d3d748b396
---> 060f6da19513
Removing intermediate container 56d3d748b396
Successfully built 060f6da19513
那就是我如何运行容器
docker run --rm --name test2 test
docker: Error response from daemon: Container command '/myinit.sh' not found or does not exist..
myinit.sh确实存在。这是ls -al
ls -al
total 16
drwxr-xr-x 4 lorddaedra staff 136 10 май 19:43 .
drwxr-xr-x 25 lorddaedra staff 850 10 май 19:42 ..
-rw-r--r-- 1 lorddaedra staff 82 10 май 19:51 Dockerfile
-rwxr-xr-x 1 lorddaedra staff 29 10 май 19:51 myinit.sh
为什么看不到我的入口点脚本?有什么办法吗?
谢谢
这不是它找不到的入口点脚本,而是它所引用的shell-alpine:3.3默认情况下内部没有bash。更改myinit.sh
为:
#!/bin/sh
set -e
echo 123
即引用/bin/sh
而不是/bin/bash
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句