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

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.

主站蜘蛛池模板: 新余市| 奉化市| 台东县| 葫芦岛市| 顺昌县| 图片| 衡阳市| 沁水县| 蓬溪县| 澜沧| 淮北市| 北流市| 哈巴河县| 福建省| 乳山市| 凤山县| 邻水| 吉木乃县| 灯塔市| 林甸县| 邹平县| 祁东县| 汝州市| 德州市| 宁都县| 古交市| 阿克苏市| 佛山市| 昆山市| 于田县| 亳州市| 通海县| 枣阳市| 怀来县| 安西县| 南安市| 简阳市| 容城县| 宜阳县| 梁河县| 海门市|