Search code examples
dockerdockerfile

Is it necessary to RUN apk update && apk upgrade in a docker build stage?


I'm creating a multi stage build docker file. In the deployment step that will actually run the program i'm running

RUN apk update && apk upgrade --no-cache

Should I also have this statement in my build stage?


Solution

  • It isn't necessary to always apk update/upgrade in your dockerfile. However it surely isn't a bad idea. Especially if you install packages with apk, you should make sure that the package list is up-to-date. So you always get the latest version of the package you want to install.

    Installing security updates on build time does matter, especially if your base image is not that recent. But I wouldn't call it necessary and it also depends on how important it is for your base image to be up-to-date.