About this question
I created a Docker image, but I forgot to name something, by default it has taken an unnamed name. Can anyone tell me how I can change the name of the Docker image?
I created a Docker image, but I forgot to name something, by default it has taken an unnamed name. Can anyone tell me how I can change the name of the Docker image?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask DevOps Expert
Answered on Jul 27, 2021
You can rename your docker image by docker tag command. Use the below given command to do that.
$ docker tag OldName:tag NewName:tagOr another way to rename docker container
To rename docker container, use the rename sub-command as shown, in the following example, we renaming the container discourse_app to a new name disc_app.
$ sudo docker rename discourse_app disc_appAfter renaming a containers, confirm that it is now using the new name.
$ sudo docker psRanjana Admin JanBask Expert Latest answer
Answered on Jan 21, 2025
Renaming a Docker image without rebuilding it is possible by leveraging Docker's tagging functionality. Essentially, Docker doesn’t support directly renaming an image, but you can achieve the same result by creating a new tag and removing the old one. Here’s how to do it:
Step 1: Tag the Existing Image with the New Name
Use the docker tag command to create a new tag for your image. This effectively gives the image a new name.
docker tag old_image_name:tag new_image_name:tagStep 2: Verify the New Image Name
After tagging, check your images to confirm the new name exists:
docker imagesStep 3: (Optional) Remove the Old Image Tag
If you no longer need the old image name, you can remove it using:
docker rmi old_image_name:tagThis will only delete the reference to the old tag, not the image data itself, since the image is still associated with the new tag.
Why This Works
Best Practices
This method is quick, efficient, and avoids the need for a time-consuming rebuild!
Ranjana Admin JanBask Expert
Answered on Apr 18, 2024
To rename Docker images without rebuilding them, you can follow these steps:
Tag the existing image with the new name: Use the docker tag command to assign a new name to the existing image. For example:
docker tag old_image_name:tag new_image_name:tagVerify the new tag: Ensure that the image has been properly tagged with the new name by listing the images:
docker imagesRemove the old tag (optional): If you want to remove the old tag while retaining the image, you can use the docker rmi command:
docker rmi old_image_name:tagBy following these steps, you can effectively rename Docker images without the need to rebuild them.