官术网_书友最值得收藏!

Using the latest tag

By default, the Docker CLI assumes a special tag called latest. This means that if you perform the docker pull applicationimage command or the docker run -it applicationimage command, or use FROM applicationimage in your Dockerfile, the applicationimage:latest tag will be used. Similarly, when you execute docker build -t applicationimage ., the resulting Docker image will be tagged with the latest tag and each subsequent build will produce a new version of applicationimage:latest.

It is important to understand that latest behaves just like any other Docker image tag. It can be seen as a default value that is always used by Docker whenever no tag has been provided by user. This has some consequences that may cause confusion, as follows:

  • During an image build, if you specify your tag for the image, the latest tag will not be added. This means that if you push applicationimage:v1 to the registry, it doesn't mean that applicationimage:latest will be updated. You have to perform it explicitly.
  • When the image owner pushes a new Docker image version to the repository and it is tagged again with the latest tag, this doesn't mean that your locally cached image will be updated and used during docker build. You have to tell the Docker CLI to attempt to pull a newer version of the image by using the --pull argument for docker build.
  • Using the latest tag for the Dockerfile's FROM instruction can lead to different images being built in different points in time, which is generally not desirable. For example, you may be building your image using the mcr.microsoft.com/dotnet/core/sdk image at a point in time when latest points to version 2.2 of the SDK, but after a few months, building the same Dockerfile will result in version 3.0 being used as the base.

The general best practice (this is also the same for Kubernetes) is to avoid deploying production containers using the latest tag and use the latest tag just for development scenarios and ease of use for your local environment. Similarly, to ensure that your Docker images are predictable and self-descriptive, you should avoid using base images with the latest tag in a Dockerfile use a specific tag instead.

主站蜘蛛池模板: 于田县| 墨竹工卡县| 三河市| 鄂托克旗| 淳安县| 永济市| 望都县| 炎陵县| 徐州市| 碌曲县| 临湘市| 外汇| 延庆县| 宁乡县| 鹤庆县| 吴忠市| 肥乡县| 阿瓦提县| 莒南县| 遂溪县| 科尔| 仪征市| 竹山县| 汕尾市| 岳阳市| 泰安市| 大足县| 来凤县| 永新县| 如皋市| 富阳市| 大荔县| 且末县| 肥乡县| 秀山| 钦州市| 诏安县| 达日县| 新郑市| 昌都县| 民县|