如果我的dockerfile中的RUN命令出错,它就会继续执行下一个命令。
答案 0 :(得分:1)
您确定该命令确实返回了错误吗?以下Dockerfile无法访问echo foo
:
FROM alpine
RUN false
RUN echo foo
它得到:
# docker build .
Sending build context to Docker daemon 3.072 kB
Step 0 : FROM alpine
---> 0a3b5ba3277d
Step 1 : RUN false
---> Running in 22485c5e763c
The command '/bin/sh -c false' returned a non-zero code: 1
要检查您的命令是否真的失败,您可以尝试这样的事情:
FROM alpine
RUN false || echo failed
RUN echo foo
然后让我:
# docker build .
Sending build context to Docker daemon 3.072 kB
Step 0 : FROM alpine
---> 0a3b5ba3277d
Step 1 : RUN false || echo failed
---> Running in 674f09ae7530
failed
---> 232fd66c5729
Removing intermediate container 674f09ae7530
Step 2 : RUN echo foo
---> Running in c7b541fdb15c
foo
---> dd1bece67e71
Removing intermediate container c7b541fdb15c
Successfully built dd1bece67e71