LinuxCommandLibrary

docker-container-rename

Rename an existing Docker container

TLDR

Rename a container

$ docker [[rename|container rename]] [container] [new_name]
copy

Display help
$ docker [[rename|container rename]] --help
copy

SYNOPSIS

docker container rename [OPTIONS] CONTAINER NEW_NAME

PARAMETERS

--help
    Print usage information

CONTAINER
    Name or ID of the container to rename

NEW_NAME
    New unique name for the container

DESCRIPTION

The docker container rename command changes the name of a Docker container, making it easier to manage and identify in lists or scripts. Containers can be referenced by long/short ID or name; this updates the name field while preserving the ID. It works on both running and stopped containers without downtime or state changes. The source container must exist, and the new name must be unique—no other container can have it. Names follow Docker conventions: lowercase letters, digits, underscores, periods, dashes, starting with letter or digit. Useful for fixing typos, standardizing names in swarms, or reorganizing after bulk creation. Run docker container ls to verify before/after. Errors occur for invalid names, duplicates, or non-existent sources.

CAVEATS

New name must be unique; fails if duplicate or invalid format. Cannot rename non-existent container. No effect on running processes.

EXAMPLE

docker container rename old-app new-app
Renames container old-app to new-app.

EXIT CODES

0: success
1: general error (e.g., invalid args, name conflict)

HISTORY

Introduced in Docker 1.0.0 (June 2014) as core CLI for container lifecycle management; syntax stabilized in later 1.x releases.

SEE ALSO

docker container ls(1), docker container rm(1), docker container create(1)

Copied to clipboard