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

Using tags

Tags are descriptors to label different versions of the same image. There's an image, alpine:3.9, and another, alpine:3.8. There are also official images of Python for different interpreters (3.6, 3.7, 2.7, and so on), but other than versions, the interpreters may refer to ways the image is created.

For example, these images have the same effect. The first one is a full image containing a Python 3.7 interpreter:

$ docker run -it python:3.7
Python 3.7.3 (default, May 8 2019, 05:28:42)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

The second one also has a Python 3.7 interpreter. Note the slim change in the name:

$ docker run -it python:3.7-slim
Python 3.7.3 (default, May 8 2019, 05:31:59)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

However, the sizes of the images are quite different:

$ docker images | grep python
python 3.7-slim ca7f9e245002 4 weeks ago 143MB
python 3.7 a4cc999cf2aa 4 weeks ago 929MB

Any build uses the latest tag automatically if another tag is not specified.

Keep in mind that tags can be overwritten. This may be confusing, given some of the similarities between the way Docker and Git work, as the term "tag" in Git means something that can't change. A tag in Docker is similar to a branch in Git.

A single image can be tagged multiple times, with different tags. For example, the latest tag can also be version v1.5:

$ docker tag thoughts-backend:latest thoughts-backend:v1.5
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
thoughts-backend latest c7a8499623e7 5 min ago 144MB
thoughts-backend v1.5 c7a8499623e7 5 min ago 144MB

Note how image id is the same. Using tags allows you to label specific images, so we know they are ready to deploy or give them some kind of significance.

主站蜘蛛池模板: 都江堰市| 库尔勒市| 怀来县| 松溪县| 腾冲县| 黄石市| 辽阳县| 澄江县| 屏南县| 桐庐县| 休宁县| 丹棱县| 年辖:市辖区| 油尖旺区| 澄城县| 右玉县| 扶绥县| 蕲春县| 民乐县| 镇江市| 宾川县| 达孜县| 西城区| 荣成市| 泰来县| 莱州市| 衡南县| 澄江县| 钟山县| 县级市| 上犹县| 莱芜市| 晋江市| 信宜市| 高唐县| 龙游县| 邳州市| 通化市| 廊坊市| 泰顺县| 翼城县|