Docker构建标签库名称 [英] Docker build tag repository name

查看:366
本文介绍了Docker构建标签库名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道的是在构建图像时可以给出的t标志。例如:

  $ docker build -t ouruser / sinatra:v2。 

根据文档,t标志用于标记和命名。名称是':'之前的部分,标签是之后的部分。所以在我们的例子中,这个名字是ususer / sinatra,标签是v2。



我以为这是图像名称和标签。但显然,这个名字其实是一些仓库名称?为什么我觉得是这样?那么,因为如果你在这个列表后面的图像与命令:

  docker图像

您将收到如下列表:

  REPOSITORY TAG IMAGE ID CREATED SIZE 
ouruser / sinatra最新5db5f8471261 11小时前446.7 M

砰!主要震撼!你以为你正在创建一个名称的图像,而是指定了一些存储库!与此有关,我有一些问题:


  1. 这个存储库位于哪里?

  2. 在没有创建存储库的情况下命名映像?

  3. 这个存储库的使用和使用方式,或者可以使用?

  4. 在哪里可以找到更多有关这个仓库?我只是发现了这一点,并不说实话: docker build docs

  5. 为什么使用由两部分组成的名称是常见的:somename / someothername?

感谢您的帮助!

解决方案

我相信这里的混乱是仓库。在Docker中,存储库是具有相同名称的图像的任何组合,以及潜在的多个标签。一个注册表服务器,如hub.docker.com或您自己的私人注册表,拥有多个存储库,例如公共注册表上的 redis存储库。那个存储库有不同版本的版本的多个标签。



所以用这个背景来回答你的问题:


  1. ouruser / sinatra位于您当地的Docker主机上,直到您执行 docker push

  2. 不,存储库和标签是映像的名称。

  3. 在本地系统上,您可以在本地使用此映像。一旦你把它推到一个注册表,你可以把它拉到任何其他可以访问该注册表的Docker主机。如果您执行 docker save ,则可以在另一台主机上将该图像保存为 docker load

  4. 我确定在docs.docker.com上有一些文档,但我从一个类中学到了。

  5. 用户名/ imagebase格式到支持在hub.docker.com中推送到您自己的命名空间。没有这样的话,任何人将第一个Redis形象称为redis,而下一个人将自己的存储库称为redis-improved,并且我们很快就陷入混乱的名字,不清楚谁做了什么和什么是一个有信誉的形象。这个命名对于本地制作的图像来说不是必需的,但仍然鼓励,因为如果由Docker自己维护,那么从hub.docker.com中抽出的图像可能会缺少用户名。没有你的用户名,你不会知道你下拉的图像和自己建立的图像。


One can easily build docker images through docker build command.

What I'm wondering is the t flag that you can give when building the image. For example:

$ docker build -t ouruser/sinatra:v2 .

According to documentation, the t flag is for tagging and naming purposes. Name is the part before ':', and tag is the part after it. So in our example, the name is ouruser/sinatra, and the tag is v2.

I thought this would be the image name and tag. But apparently, the name is actually some repository name? Why do I think it is? Well, because if you would after this list the images with command:

docker images

You would get a listing like this:

REPOSITORY          TAG     IMAGE ID      CREATED        SIZE
ouruser/sinatra     latest  5db5f8471261  11 hours ago   446.7 M

Bang! Major shock! You thought you were creating an image with name, and instead, you specified some repository! Related to this, I have some questions:

  1. Where is this repository located?
  2. Can I name the image without creating a repository?
  3. Where and how is this repository used, or could be used?
  4. Where can I find more information about this repository? I only found this, and it doesn't tell much to be honest: docker build docs
  5. Why is it common to use names that consist of two parts like this: somename/someothername?

Thank you for your help!

解决方案

I believe the confusion here is the word "repository." In Docker, a repository is any group of builds of an image with the same name, and potentially multiple tags. A "registry" server, like hub.docker.com or your own private registry, holds multiple repositories, e.g. the redis repository on the public registry. That one repository has multiple tags for different versions of the build.

So with that background, to answer your questions:

  1. ouruser/sinatra is located on your local Docker host until you do a docker push
  2. No, the repository and the tag is the name of the image.
  3. While local on your system, you can use this image locally. Once you push it up to a registry, you can then pull it down to any other Docker host that has access to that registry. And if you do a docker save you can save that image for a docker load on another host.
  4. I'm sure there is documentation covering this somewhere on docs.docker.com, but I learned from a class.
  5. The username/imagebase format came about to support pushing to your own namespace in hub.docker.com. Without that, whoever makes the first "Redis" image calls it "redis" while the next person makes their own repository called "redis-improved", and we quickly get into a jumble of confusing names where it's not clear who made what and what is a reputable image. That naming isn't required for images you make locally, but is still encouraged since images you pull from hub.docker.com may lack a username if they are maintained by Docker themselves. Without your username, you won't know which images you pulled down and which you built yourself.

这篇关于Docker构建标签库名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆