Docker error: invalid reference format: repository name must be lowercase

前端 未结 22 1886
孤独总比滥情好
孤独总比滥情好 2020-12-12 23:07

Ran into this Docker error with one of my projects:

invalid reference format: repository name must be lowercase

What are the various causes for

相关标签:
22条回答
  • 2020-12-12 23:45

    A "reference" in docker is a pointer to an image. It may be an image name, an image ID, include a registry server in the name, use a sha256 tag to pin the image, and anything else that can be used to point to the image you want to run.

    The invalid reference format error message means docker cannot convert the string you've provided to an image. This may be an invalid name, or it may be from a parsing error earlier in the docker run command line if that's how you run the image. With a compose file, if you expand a variable in the image name, that variable may not be expanding correctly.

    With the docker run command line, this is often the result in not quoting parameters with spaces, and mistaking the order of the command line. The command line is ordered as:

    docker ${args_to_docker} run ${args_to_run} image_ref ${cmd_to_exec}
    

    The most common error in passing args to the run is a volume mapping expanding a path name that includes a space in it, and not quoting the path or escaping the space. E.g.

    docker run -v $(pwd):/data image_ref
    

    And the fix is as easy as:

    docker run -v "$(pwd):/data" image_ref
    
    0 讨论(0)
  • 2020-12-12 23:45

    In my case I was trying to run postgres through docker. Initially I was running as :

    docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=test_password POSTGRES_USER=test_user POSTGRES_DB=test_db --rm -v ~/docker/volumes/postgres:/var/lib/postgresql/data --name pg-docker postgres

    I was missing -e after each environment variable. Changing the above command to the one below worked

    docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=test_password -e POSTGRES_USER=test_user -e POSTGRES_DB=test_db --rm -v ~/docker/volumes/postgres:/var/lib/postgresql/data --name pg-docker postgres

    0 讨论(0)
  • 2020-12-12 23:46

    I wish the error message would output the problem string. I was getting this due to a weird copy and paste problem of a "docker run" command. A space-like character was being used before the repo and image name.

    0 讨论(0)
  • 2020-12-12 23:47

    I had the same error, and for some reason it appears to have been cause by uppercase letters in the Jenkins job that ran the docker run command.

    0 讨论(0)
  • 2020-12-12 23:49

    Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. example: FROM python:3.7-alpine The 'python' should be in lowercase

    0 讨论(0)
  • 2020-12-12 23:51

    Indeed, the docker registry as of today (sha 2e2f252f3c88679f1207d87d57c07af6819a1a17e22573bcef32804122d2f305) does not handle paths containing upper-case characters. This is obviously a poor design choice, probably due to wanting to maintain compatible with certain operating systems that do not distinguish case at the file level (ie, windows).

    If one authenticates for a scope and tries to fetch a non-existing repository with all lowercase, the output is

    (auth step not shown)
    curl -s -H "Authorization: Bearer $TOKEN" -X GET https://$LOCALREGISTRY/v2/test/someproject/tags/list
    {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"test/someproject","Action":"pull"}]}]}
    

    However, if one tries to do this with an uppercase component, only 404 is returned:

    (authorization step done but not shown here)
    $ curl -s -H "Authorization: Bearer $TOKEN" -X GET https://docker.uibk.ac.at:443/v2/test/Someproject/tags/list
    
    404 page not found
    
    0 讨论(0)
提交回复
热议问题