【发布时间】:2017-12-01 21:45:16
【问题描述】:
我的目录只包含两个文件,Dockerfile 和 sayhello.sh:
.
├── Dockerfile
└── sayhello.sh
Dockerfile 读取
FROM alpine
COPY sayhello.sh sayhello.sh
CMD ["sayhello.sh"]
而sayhello.sh 包含简单
echo hello
Dockerfile 构建成功:
kurtpeek@Sophiemaries-MacBook-Pro ~/d/s/trybash> docker build --tag trybash .
Sending build context to Docker daemon 3.072 kB
Step 1/3 : FROM alpine
---> 665ffb03bfae
Step 2/3 : COPY sayhello.sh sayhello.sh
---> Using cache
---> fe41f2497715
Step 3/3 : CMD sayhello.sh
---> Using cache
---> dfcc26c78541
Successfully built dfcc26c78541
但是,如果我尝试 run 它,我会收到 executable file not found in $PATH 错误:
kurtpeek@Sophiemaries-MacBook-Pro ~/d/s/trybash> docker run trybash
container_linux.go:247: starting container process caused "exec: \"sayhello.sh\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"sayhello.sh\": executable file not found in $PATH".
ERRO[0001] error getting events from daemon: net/http: request canceled
这是什么原因造成的?我记得以类似的方式在基于debian:jessie 的图像中运行脚本。所以也许它是 Alpine 特有的?
【问题讨论】:
标签: docker dockerfile alpine