How to assign a name to running container in docker?

Pratik Patel picture Pratik Patel · Nov 9, 2016 · Viewed 7.7k times · Source

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?

Answer

VonC picture VonC · Nov 9, 2016

Check if docker rename works for a running container:

docker rename 345df9ed5b47 new_name

(This is for docker 1.10+, from PR 8570)