Docker: How to Name or Rename a Container

Updated: November 9, 2021 By: A Goodman Post a comment

You can do everything you want with a Docker container just by using its ID. That being said, giving a container a meaningful and human-friendly name will make your day more joyful and convenient.


To name a Docker container, we use the –name flag when running the docker run command (a name cannot be used twice, otherwise a conflict error will occur):


docker run -d --name kindacode_example -it ubuntu sh

To verify that everything is fine, run:

docker container ls

You will get a result similar to this:


If you don’t happy with a container’s name, you can change it:

docker rename old-name new-name


docker rename kindacode_example new_name

Do some check:

docker ps

And you will see:


You’ve learned how to name and rename a container in Docker. If you’d like to explore more about this awesome technology, take a look at the following articles:

You can also check out our Docker topic page for the latest tutorials, examples, tips, and tricks.

Notify of
Inline Feedbacks
View all comments

Related Articles