This guide demonstrated the process of setting the default Docker container name.
How to Set a Default Docker Container Name?
To set a default container name, try out the following instructions:
- Login to Docker by using the docker login command.
- Run the docker ps -a command to get the names of all the available containers.
- From there simply choose the selected one to change.
- Execute the docker rename <old-name> <new-name> command.
Step 1: Login to Docker
Initially, execute the docker login command and login to Docker:
Step 2: List All Containers
To display all the available containers including stopped and running, execute the provided command:
Here, we have selected the below-highlighted container named perk_con to which we want to rename:
Step 3: Rename Container
Now, execute the docker rename command along with the existing container name and a new name:
Here, the perk_con is the previous name of the container and logitech is the new name:
Step 4: Verification
Lastly, verify whether the container was renamed successfully or not by executing the below-mentioned command:
According to the provided output, the container name has been renamed successfully:
That’s it! We have provided a method for setting the default Docker container name.
Conclusion
To set the default Docker container name, first, login to Docker by using the docker login command. Then, list all the existing containers and select one of them to which you need to change. After that, execute the docker rename <old-name> <new-name> command. This guide demonstrated the process of setting the default Docker container name.