Update container images (some clarification)

  1. Does the following command update the repository, OS, and all software in the container, except the host system hosting Docker?
    RUN apt update && apt upgrade -y
  2. Is it okay to add this line of code in each Dockerfile?
  3. Is it convenient to use this RUN command?
  4. Why do I get this error if I add the command to the Dockerfile?
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
  5. Why do I get a serious error with the following image and everything stops?
    FROM dpage/pgadmin4:latest
Step 4/4 : RUN apt update && apt upgrade -y
 ---> Running in 5b1531dcb8a9
/bin/sh: apt: not found
The command '/bin/sh -c apt update && apt upgrade -y' returned a non-zero code: 127
ERROR: Service 'pgadmin' failed to build : Build failed
  1. A system engineer told me not to use ‘-get’ because it is a deprecated command, is it true?

Seems you didn’t come far with the docker training I suggested severall topics ago.

It depends on the base image what package manager will be available. Only images for Debian based OSes (Debian, Ubuntu, forks of those) provide apt and/or apt-get. apt-get is still the official tool to install packages on Debian based system, but I haven’t encountered any problems using apt as well - you only the the warning (this is NOT an error!) you quoted in #4. Just because a new way is available doesn’t necessarily mean the old way is deprecated, unless the maintainer indicates that it is - I can’t find any changelog that supports the claim that apt-get is deprecated.

It depends on your strategy, if you want to rely on the patch level of the base image (which only makes sense if it’s regularly updated) or want to have the latests os packages in your image. Be aware that upgrading packes will result in a bigger image size, as nothing is deleted or replaced from the base image. An additional image layer will be created on top of the existing layers with the new files - additionaly it will set marks for deleted/replaced files compared to it’s parent layer.

Those are the parts I can address, someone else needs to respond to the rest and pick up from here.

1 Like

All very clear, thank you very much.
I have tried these codes and they don’t work.

RUN yum -y update
RUN yum clean all
RUN yum clean expire-cache && yum update