4-Docker命令之docker rename

2023-12-13 03:35:13

1.docker rename介绍

docker rename命令是用于重命名一个docker容器

2.docker rename用法

docker rename container New_Name

[root@centos79 ~]# docker rename --help

Usage:  docker rename CONTAINER NEW_NAME

Rename a container

Aliases:
  docker container rename, docker rename
[root@centos79 ~]# 

3.实例

3.1.重命名运行的容器名称

命令:

docker rename centos-nginx centos-nginx-1.0

[root@centos79 ~]# docker ps | grep 42574
425747b4385b   centos-nginx:1.0       "nginx -g 'daemon of…"   4 days ago    Up 2 hours   0.0.0.0:80->80/tcp, :::80->80/tcp                                                      centos-nginx
[root@centos79 ~]# docker rename centos-nginx centos-nginx-1.0
[root@centos79 ~]# docker ps | grep 42574
425747b4385b   centos-nginx:1.0       "nginx -g 'daemon of…"   4 days ago    Up 2 hours   0.0.0.0:80->80/tcp, :::80->80/tcp                                                      centos-nginx-1.0
[root@centos79 ~]# 

3.2.重命名未运行的容器名称

命令:

docker rename busy_taussig hello-world

[root@centos79 ~]# docker ps -a | grep 8f8686
8f86869d31a8   hello-world            "/hello"                  3 days ago    Exited (0) 3 days ago                                                                                            busy_taussig
[root@centos79 ~]# docker rename busy_taussig hello-world
[root@centos79 ~]# docker ps -a | grep 8f8686
8f86869d31a8   hello-world            "/hello"                  3 days ago    Exited (0) 3 days ago                                                                                            hello-world
[root@centos79 ~]# 

文章来源:https://blog.csdn.net/z19861216/article/details/134639104
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。