Docker如何更改存储库名称或重命名图像?

本文介绍了如何更改Docker图像的存储库名称。用户提问如何将图像名称从旧名称更改为新名称,得到了多个回答。其中一个建议是使用`docker tag`命令进行重命名,并在重新标记后可以删除旧的标签。另一个建议是通过`docker run`命令直接为现有图像指定新名称。此外,还提到在迁移Docker图像到不同注册表时可能需要的重命名过程。
摘要由CSDN通过智能技术生成

本文翻译自:Docker how to change repository name or rename image?

I'm trying to change repository name of the image: 我正在尝试更改图像的存储库名称:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
server              latest              d583c3ac45fd        26 minutes ago      685.5 MB

Hence I want to change the name server to something like myname/server : 因此,我想将名称server更改为myname/server

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
myname/server       latest              d583c3ac45fd        26 minutes ago      685.5 MB

How can I do this? 我怎样才能做到这一点?


#1楼

参考:https://stackoom.com/question/1hmaE/Docker如何更改存储库名称或重命名图像


#2楼

docker tag server:latest myname/server:latest

or 要么

docker tag d583c3ac45fd myname/server:latest

Tags are just human-readable aliases for the full image name ( d583c3ac45fd... ). 标签只是完整图像名称的人类可读别名( d583c3ac45fd... )。

So you can have as many of them associated with the same image as you like. 因此,您可以将尽可能多的图像与您想要的相同图像相关联。 If you don't like the old name you can remove it after you've retagged it: 如果您不喜欢旧名称,可以在重新标记后将其删除:

docker rmi server

That will just remove the alias/tag . 那只会删除alias/tag Since d583c3ac45fd has other names, the actual image won't be deleted. 由于d583c3ac45fd具有其他名称,因此不会删除实际图像。


#3楼

As a shorthand you can run: 作为简写,你可以运行:

docker tag d58 myname/server:latest

Where d58 represents the first 3 characters of the IMAGE ID,in this case, that's all you need. 其中d58代表IMAGE ID的前3个字符,在这种情况下,这就是你所需要的。

Finally, you can remove the old image as follows: 最后,您可以删除旧图像,如下所示:

docker rmi server

#4楼

docker run -it --name NEW_NAME Existing_name docker run -it --name NEW_NAME Existing_name

To change the existing image name. 要更改现有图像名称。


#5楼

docker tag CURRENT_IMAGE_NAME DESIRED_IMAGE_NAME

#6楼

Recently I had to migrate some images from Docker registry (docker.mycompany.com) to Artifactory (docker.artifactory.mycompany.com) 最近我不得不将一些图像从Docker注册表(docker.mycompany.com)迁移到Artifactory(docker.artifactory.mycompany.com)

docker pull docker.mycompany.com/something/redis:4.0.10
docker tag docker.mycompany.com/something/redis:4.0.10 docker.artifactory.mycompany.com/something/redis:4.0.10
docker push docker.artifactory.mycompany.com/something/redis:4.0.10
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值