的构建过程创建一个中间的dockerfile中的每一步。就像你可以在这个例子中看到的那样:
...
Removing intermediate container e07079f73a9f
Step 3 : RUN cd /opt/
---> Running in 78d480a57cca
---> 324e9006d642
Removing intermediate container 78d480a57cca
Step 4 : RUN unzip /opt/mule-ee-distribution-standalone-3.7.3.zip -d /opt/
---> Running in 81aa445c770c
...
---> e702e1cff4ee
---> removing intermediate container 81aa445c770c
为了加快构建过程,中间容器将被用作缓存。这些容器将在成功构建后被删除,但是当您尝试多次构建“旧”中间容器和图像时,它们仍将存在于您的系统中。
如果您希望在构建完成后保留中间容器,则必须使用--rm=false
。默认情况下它是true
,所以在成功构建之后,中间容器将被删除。在使用中间容器期间构建失败时,该容器将退出。这个容器的中间'图像'有标签<none>:<none>
,并且不能正常删除,因为这个图像有一个(兴奋的)容器。您可以使用-f(强制)标志删除图像:docker rmi -f image-id