docker-container-rename
Rename an existing Docker container
TLDR
View documentation for the original command
SYNOPSIS
docker container rename OLD_NAME NEW_NAME
docker rename OLD_NAME NEW_NAME (alias)
PARAMETERS
--help
Display help for the command.
DESCRIPTION
The docker container rename command is a fundamental Docker CLI utility used to change the name of an existing container. This operation allows users to assign a more descriptive, mnemonic, or convenient name to a container after its creation. Renaming is particularly useful for improving the manageability and identification of containers, especially in environments with numerous running instances. The command takes two primary arguments: the current name or ID of the container to be renamed, and the desired new name. It's important to note that the new name must be unique among all containers managed by the Docker daemon; if a container with the specified new name already exists, the command will fail. This flexibility enables users to rename both running and stopped containers without affecting their internal state, configuration, or allocated resources, simplifying container orchestration and enhancing readability when listing containers.
CAVEATS
The NEW_NAME must be unique across all containers managed by your Docker daemon; attempting to use an already existing name will result in an error. Renaming a container does not change its unique ID or its internal configuration, only its externally referenced name. While renaming can be performed on both running and stopped containers, for containers part of orchestrated systems like Docker Compose or Swarm, it is generally recommended to modify the service definition rather than manually renaming individual containers to maintain consistency and avoid unexpected behavior.
ALIASES
For backward compatibility and user convenience, docker rename acts as an alias for docker container rename. Both commands perform the identical operation.
ARGUMENTS
The command requires two positional arguments: OLD_NAME, which can be the container's current name or its short/long ID, and NEW_NAME, the desired unique name for the container.
HISTORY
The ability to rename containers has been a core feature of the Docker CLI since its early development, reflecting the need for flexible container management. Initially available as docker rename, the command was later aliased by docker container rename with the introduction of Docker Engine 1.13. This change was part of a broader initiative to restructure the Docker CLI, grouping subcommands under specific object types (e.g., container, image, network). This reorganization aimed to create a more consistent, intuitive, and scalable command-line interface, making it easier for users to discover and utilize commands as the Docker platform grew in complexity and capability.