I have created container from particular image using command:
$ docker run -d -P selenium/hub
running container status is below:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
345df9ed5b47 selenium/hub "/opt/bin/entry_point" 5 seconds ago Up 4 seconds 0.0.0.0:32768->4444/tcp clever_williams
Here default name is "clever_williams" and I forgot to assign new name to it I need to change default name to running container so how can I do that?
When a container is created using Docker, Docker provides a way to name the container using the the --name <container_name> flag. However, if no name is provided by the user while creating/running a Docker container, Docker automatically assigns the container a name.
FreeKB - Docker Assign a name to a container using the docker run --name command. When creating a container using the docker run command, the --name option can be used to give the container a specific name. In this example, a container is created using the foo:latest image, and the name of the container will be foo.
Running the command "sudo nsenter --target 1 --uts hostname <my new hostname>" from inside the container did the trick.
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. After renaming a containers, confirm that it is now using the new name.
Check if docker rename
works for a running container:
docker rename 345df9ed5b47 new_name
(This is for docker 1.10+, from PR 8570)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With