Docker Community Forums

Share and learn in the Docker community.

Can you force a build?

build

(Vrms) #1

I m building my own image FROM debian:8

main part of the build process is running an installation script which clones a repository from github.

Now in case that github repo was updated my build process still uses the existing layers when I run my docker build which results into an identical image as outcome, doesn’t it?

Is there any way to force rebuilding existing layers so the installation script is being executed and therefore I actually have an updated image of the application I am want to run?

by default I only would get something new if the base image (debian:8 in my case) was updated and I pulled that before the build I think


(David Maze) #2

Yes.

docker build --no-cache is probably what you’re looking for here.

I almost always use a two-phase build process, where things like source code that can change get pulled in outside of the docker build process and COPYed in. Then if it hasn’t actually changed, you get the “fast” cached build sequence, and if it has, whatever rebuilding is necessary gets done.


(Dvohra) #3

Container platforms such as Openshift Origin rebuild a Docker image automatically when a github is updated.
https://www.openshift.org/?sc_cid=701600000011p9xAAA&gclid=CL3prc7Apc0CFYVrfgodrqEMSg


(Vrms) #4

@dvohra openshift looks interesting, but for my current scenario a bit of an overkill still. I’ll go with the `build --no-cache’ for the moment.


(Vrms) #5

that seems like the smartest solution. So build actually ‘understands’ whether what’s COPY'd from outside is actually different then what’s already in the cache? … sounds pretty clever