Search code examples
dockerdocker-image

How to give a simple repository-name to docker image


docker image pull requires exactly 1 argument docker image pull [OPTIONS] NAME[:TAG]

When we download images from non standard repositories, a big REPOSITORY URL is prepended in docker image ls output.

Action
If I run following command

docker image pull artifactory-url/namespace/mydockerImage:123

Current behavior
The image listing will return

$ docker image ls  -a
REPOSITORY                                TAG          IMAGE ID       CREATED          SIZE    
artifactory-url/namespace/mydockerImage   123          acvsx1234     48 minutes ago    1.54GB  

Expected behavior
Is there any option or other command I can use while pulling so I can have docker listing output as following ?

$ docker image ls  -a
    REPOSITORY      TAG          IMAGE ID       CREATED          SIZE    
    mydockerImage   123          acvsx1234     48 minutes ago    1.54GB 

Solution

  • You can retag the image and remove the old image.

    e.g.

    # Pull image
    docker image pull artifactory-url/namespace/mydockerImage:123
    # Retag image
    docker tag artifactory-url/namespace/mydockerImage:123 myFunName:123
    # Remove old tag (does not remove image as long as one tag points to it)
    docker rmi artifactory-url/namespace/mydockerImage:123