Home > Software design >  Is it necessary to RUN apk update && apk upgrade in a docker build stage?
Is it necessary to RUN apk update && apk upgrade in a docker build stage?

Time:04-29

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?

CodePudding user response:

Well, it depends, it has both benefits and drawbacks. Two links I found where they go through the idea of both approaches:

CodePudding user response:

It isn't necessary to always apt update/upgrade in your dockerfile. However it surely isn't a bad idea. Especially if you install packages with apt, 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.

  • Related