Rename a stopped container

Viewed 41

I ran a container sometime back and now it's killed. Now I want to start another container with the same name but don't want to remove the existing container. Is there any way I can rename the stopped container?

I had this container running with the name test-exit

129345a41ce3   python3.10   "start_command.sh"   About an hour ago   Exited (255) 4 minutes ago test-exit                                                                                                             

Now that it's stopped. I want to preserve it with the name test-exit-trail-1 and start another container with the name test-exit. Is there any way I can do that?

It should be trivial I guess. I might be missing some right keywords to search on google.

2 Answers

Try

docker rename old-name new-name

Example

docker rename test-exit new_name

Do some check:

docker container ls -a

Looking at the documentation man docker

docker container rename old-name new-name 
Related