How to force Docker for a clean build of an image

后端 未结 9 935
情书的邮戳
情书的邮戳 2021-01-29 17:12

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

9条回答
  •  孤城傲影
    2021-01-29 17:36

    I would not recommend using --no-cache in your case.

    You are running a couple of installations from step 3 to 9 (I would, by the way, prefer using a one liner) and if you don't want the overhead of re-running these steps each time you are building your image you can modify your Dockerfile with a temporary step prior to your wget instruction.

    I use to do something like RUN ls . and change it to RUN ls ./ then RUN ls ./. and so on for each modification done on the tarball retrieved by wget

    You can of course do something like RUN echo 'test1' > test && rm test increasing the number in 'test1 for each iteration.

    It looks dirty, but as far as I know it's the most efficient way to continue benefiting from the cache system of Docker, which saves time when you have many layers...

提交回复
热议问题