
Busting Docker Build Cache on Demand with ARG CACHEBUST (and Why You'd Need It)
When you're deploying to Railway (or any Docker-based platform), you'll eventually hit this: your Dockerfile runs a fresh build, but a dependency you just fixed isn't there . Docker cached the old layer. You re-deploy. Same result. Here's what's actually happening — and two concrete fixes. The Problem: Docker Caches Too Aggressively Docker builds images layer by layer. Each RUN , COPY , or ADD instruction produces a layer. If nothing in that layer's inputs changed, Docker reuses the cached version. This is great for speed. It's terrible when you need a layer to actually re-run — for example, when: You fixed a version or config in the same RUN that installed a large dependency A curl -installed tool (like yt-dlp ) needs to pull fresh You're debugging and want a guaranteed clean state Fix 1: Merge Related RUN Commands This is the one that surprises developers most. Don't do this: RUN pip install yt-dlp RUN curl -fsSL https://deno.land/install.sh | sh Docker caches these as two separate l
Continue reading on Dev.to DevOps
Opens in a new tab



