What is the difference between an image and a repository?

前端 未结 5 1568
既然无缘
既然无缘 2021-01-31 08:30

I am brand new to Docker and following the Getting Started tutorial. At step 7 it says

type docker images command and press RETURN. The comma

5条回答
  •  借酒劲吻你
    2021-01-31 08:55

    Images are built by running docker build with a given Dockerfile and are identified by their ID.

    Repositories and Tags are just means to name and organize your images in a meaningful hierarchies/architectures.

    • A repository typically contains multiple related images

    • An image can go into multiple repositories

    The following, from this SO answer, gives detailed explanation of docker imagesoutput (This is probably what they should have put in the docs):

    1. IMAGE ID is the first 12 characters of the true identifier for an image. You can create many tags of a given image, but their IDs will all be the same (as above).

    2. The value in the REPOSITORY column comes from the -t flag of the docker build command, or from docker tag-ing an existing image. You're free to tag images using a nomenclature that makes sense to you, but know that docker will use the tag as the registry location in a docker push or docker pull.

    3. The full form of a tag is [REGISTRYHOST/][USERNAME/]NAME[:TAG]. For ubuntu above, REGISTRYHOST is inferred to be registry.hub.docker.com. So if you plan on storing your image called my-application in a registry at docker.example.com, you should tag that image docker.example.com/my-application.
    4. The TAG column is just the [:TAG] part of the full tag. This is unfortunate terminology.

提交回复
热议问题