Docker images have a tag named latest which doesn’t work as you expect. A tag is an alias for a specific image version. One of the biggest confusions around the tagging is the “latest” tag. It’s in theory used for the latest image version available but because it’s manually managed, we have no guarantee it’s really the case. Maybe the maintainer manages the latest tag in his own way or just forgot to update the tag. Also, using a fixed tag like “latest” mean that the image version can change and so rebuilding an image can bring some side effects. It’s recommended to use a specific tag like the image version. This version is upgraded when you are ready with a proper life cycle management.
Example: -
FROM ubuntu
COPY . /app
RUN apt-get update\
&& apt-get -y install openjdk-8
CMD [“java”, “-jar”, “/app/app.jar”]
Instead use this image
FROM openjdk-8
COPY . /app
CMD [“java”, “-jar”, “/app/app.jar”]