如何强制Docker进行映像的干净构建

编程入门 行业动态 更新时间:2024-10-11 23:16:43
本文介绍了如何强制Docker进行映像的干净构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已使用以下命令从Docker文件构建了Docker映像。

I have build a Docker image from a Docker file using the below command.

$ docker build -t u12_core -f u12_core .

当我尝试使用同一命令对其进行重建时,它正在使用构建缓存,例如:

When I am trying to rebuild it with the same command, it's using the build cache like:

Step 1 : FROM ubuntu:12.04 ---> eb965dfb09d2 Step 2 : MAINTAINER Pavan Gupta <pavan.gupta@gmail> ---> Using cache ---> 4354ccf9dcd8 Step 3 : RUN apt-get update ---> Using cache ---> bcbca2fcf204 Step 4 : RUN apt-get install -y openjdk-7-jdk ---> Using cache ---> 103f1a261d44 Step 5 : RUN apt-get install -y openssh-server ---> Using cache ---> dde41f8d0904 Step 6 : RUN apt-get install -y git-core ---> Using cache ---> 9be002f08b6a Step 7 : RUN apt-get install -y build-essential ---> Using cache ---> a752fd73a698 Step 8 : RUN apt-get install -y logrotate ---> Using cache ---> 93bca09b509d Step 9 : RUN apt-get install -y lsb-release ---> Using cache ---> fd4d10cf18bc Step 10 : RUN mkdir /var/run/sshd ---> Using cache ---> 63b4ecc39ff0 Step 11 : RUN echo 'root:root' | chpasswd ---> Using cache ---> 9532e31518a6 Step 12 : RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config ---> Using cache ---> 47d1660bd544 Step 13 : RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd ---> Using cache ---> d1f97f1c52f7 Step 14 : RUN wget -O aerospike.tgz 'aerospike/download/server/latest/artifact/ubuntu12' ---> Using cache ---> bd7dde7a98b9 Step 15 : RUN tar -xvf aerospike.tgz ---> Using cache ---> 54adaa09921f Step 16 : RUN dpkg -i aerospike-server-community-*/*.deb ---> Using cache ---> 11aba013eea5 Step 17 : EXPOSE 22 3000 3001 3002 3003 ---> Using cache ---> e33aaa78a931 Step 18 : CMD /usr/sbin/sshd -D ---> Using cache ---> 25f5fe70fa84 Successfully built 25f5fe70fa84

缓存显示已安装了Aerospike。但是,我找不到从该图像生成的容器中的图像,因此我想在不使用缓存的情况下重建该图像。如何强制Docker在没有缓存的情况下重建干净的映像?

The cache shows that aerospike is installed. However, I don't find it inside containers spawn from this image, so I want to rebuild this image without using the cache. How can I force Docker to rebuild a clean image without the cache?

推荐答案

有一个-否-cache 选项:

docker build --no-cache -t u12_core -f u12_core .

在旧版本的Docker中,您需要传递-no-cache =正确,但情况不再如此。

In older versions of Docker you needed to pass --no-cache=true, but this is no longer the case.

更多推荐

如何强制Docker进行映像的干净构建

本文发布于:2023-10-27 04:29:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532319.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:映像   干净   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!