本文翻译自: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