我正在尝试更改图像的存储库名称:

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

因此,我想将名称服务器更改为类似myname/server的名称:

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

我该怎么做?


当前回答

如何重命名图像?

要复制图像或重命名现有图像,只需从现有图像创建新标记或存储库。您可以使用docker标记命令执行此操作。


syntax/command:  docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

#=> docker images
REPOSITORY                    TAG                   IMAGE ID       CREATED        SIZE
ubuntu-git                    latest                c0aaaba33a60   18 hours ago   208MB

docker tag ubuntu-git:latest ubuntu-git:latest-new-tag

#=> docker images
REPOSITORY                    TAG                   IMAGE ID       CREATED        SIZE
ubuntu-git                    latest                c0aaaba33a60   18 hours ago   208MB
ubuntu-git                    latest-new-tag        c0aaaba33a60   18 hours ago   208MB 

其他回答

docker image tag #imageId myname/server:latest

这对我有用

您可以使用以下命令更改多个repo/tag标记:

docker images --filter=reference='server' --format='{{.Repository}}:{{.Tag}}' | xargs -r -P$(nproc) -I {} docker image tag {} myname/{}
docker tag CURRENT_IMAGE_NAME DESIRED_IMAGE_NAME

根据码头工人文件https://docs.docker.com/engine/reference/commandline/rename/

docker rename CONTAINER NEW_NAME

如何重命名图像?

要复制图像或重命名现有图像,只需从现有图像创建新标记或存储库。您可以使用docker标记命令执行此操作。


syntax/command:  docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

#=> docker images
REPOSITORY                    TAG                   IMAGE ID       CREATED        SIZE
ubuntu-git                    latest                c0aaaba33a60   18 hours ago   208MB

docker tag ubuntu-git:latest ubuntu-git:latest-new-tag

#=> docker images
REPOSITORY                    TAG                   IMAGE ID       CREATED        SIZE
ubuntu-git                    latest                c0aaaba33a60   18 hours ago   208MB
ubuntu-git                    latest-new-tag        c0aaaba33a60   18 hours ago   208MB