Kinda Code
Home/Flutter/Docker: How to Name or Rename a Container

Docker: How to Name or Rename a Container

Last updated: November 09, 2021

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.

Table of Contents

  1. Naming
  2. Renaming
  3. Conclusion

Naming

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):

Example:

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:

Renaming

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

docker rename old-name new-name

Example:

docker rename kindacode_example new_name

Do some check:

docker ps

And you will see:

Conclusion

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.