4-Docker command docker rename

1.Introduction to docker rename

The docker rename command is used to rename a docker container

2.docker rename usage

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.Examples

3.1. Rename the running container name

Order:

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. Rename the container name that is not running

Order:

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 ~]# 

Guess you like

Origin blog.csdn.net/z19861216/article/details/134639104