linuxdockercontainersboot2docker

How to assign a name to running container in docker?


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?


Solution

  • Check the docker rename command, it works for either a running or stopped container, the pattern is:

    docker rename old_name new_name
    

    Therefore according with your provided data it can be:

    docker rename clever_williams new_name
    

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