在Windows 10上,当我运行时:

$ docker build .

我在控制台中收到此错误:
 RUN /provision/provision.sh
 ---> Running in e66928c3c893
/bin/sh: 1: /provision/provision.sh: not found

我的文件夹文件:
/Dockerfile
/provision
/provision/provision.sh

那么,尽管/bin/sh: 1: /provision/provision.sh: not found存在,为什么会出现/provision/provision.sh错误?

编辑

我试过了:
添加/设置

我尝试过:
COPY provision /provision

没用..
Step 7 : COPY provision /provision
 ---> c5d07de6948d
Removing intermediate container 85768981a7f0
Step 8 : RUN /provision/provision.sh
 ---> Running in 8426a8526514
/bin/sh: 1: /provision/provision.sh: not found
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
The command '/bin/sh -c /provision/provision.sh' returned a non-zero code: 127

最佳答案

provision/provision.sh存在于主机上的docker build context中,但您需要先将copy ( COPY )附加到图像上:

COPY provision/provision.sh /provision/provision.sh
# or
COPY provision /provision/
RUN chmod 755 /provision/provision.sh && \
    /provision/provision.sh
如文档中所述:

RUN 将在一个中间容器中执行命令,该中间容器中将Dockerfile内容编译到该行。
这意味着它在容器的上下文中而不是在主机的上下文中执行某些操作。

关于docker - 为什么没有找到,尽管它确实存在?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35519658/

10-16 20:08