在Windows 10,当我跑:
ALTER TABLE `treat_well`.`tw_venue` ADD CONSTRAINT `FK_tw_venue_user_id` FOREIGN KEY (`user_id`)
REFERENCES `bitnami_dreamfactory`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
我在控制台中收到此错误:
$ 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
存在?
修改
我试过了: ADD条款/条款
我试过了:
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
答案 0 :(得分:2)
provision/provision.sh
,但您需要copy (COPY
)首先查看该图片:
COPY provision/provision.sh /provision/provision.sh
# or
COPY provision /provision/
RUN chmod 755 /provision/provision.sh && \
/provision/provision.sh
如文档中所述:
如果
<src>
是目录,则复制目录的全部内容,包括文件系统元数据。注意:目录本身不会被复制,只会复制其内容。
RUN
将在使用编译到该行的Dockerfile内容启动的中间容器中执行命令。
这意味着它在容器的上下文中执行某些操作,而不是在主机的上下文中执行。
答案 1 :(得分:2)
在我的例子中,provision.sh文件是一个dos行结束文件。我需要使用Unix行结尾重新保存文件。
我发现这两个答案对解决问题很有帮助:
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
在Using the RUN instruction in a Dockerfile with 'source' does not work
而且: