...

/

Caching Issues

Caching Issues

Our Dockerfile has a slight issue with how the caching works. In this lesson, we will discuss these caching issues.

Caching issue 1: updating packages

Currently, our Dockerfile has the following two lines:

RUN apt-get update -yqq 
RUN apt-get install -yqq --no-install-recommends nodejs 

Although this works, there is a hidden problem. Let’s say we realize at a later stage that we need to install an extra package, for example, the Vim editor. We add the vim package to the apt-get install RUN instruction, busting the cache and causing that instruction to rerun:

RUN apt-get update -yqq 
RUN apt-get install -yqq --no-install-recommends nodejs vim 

However, the apt-get update RUN instruction remains unchanged, and the cached repository details are used. Rather than getting the current, latest version of the new package we have added, we will be ...