Docker error: invalid reference format: repository

2020-05-18 04:24发布

Ran into this Docker error with one of my projects:

invalid reference format: repository name must be lowercase

What are the various causes for this generic message?

I already figured it out after some effort, so I'm going to answer my own question in order to document it here as the solution doesn't come up right away when doing a web search and also because this error message doesn't describe the direct problem Docker encounters.

20条回答
来,给爷笑一个
2楼-- · 2020-05-18 04:50

had a space in the current working directory and usign $(pwd) to map volumes. Doesn't like spaces in directory names.

查看更多
等我变得足够好
3楼-- · 2020-05-18 04:50

On MacOS when your are working on an iCloud drive, your $PWD will contain a directory "Mobile Documents". It does not seem to like the space!

As a workaround, I copied my project to local drive where there is no space in the path to my project folder.

I do not see a way you can get around changnig the default path to iCloud which is ~/Library/Mobile Documents/com~apple~CloudDocs

The space in the path in "Mobile Documents" seems to be what docker run does not like.

查看更多
来,给爷笑一个
4楼-- · 2020-05-18 04:57

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
查看更多
唯我独甜
5楼-- · 2020-05-18 04:58

This is happening because of the spaces in the current working directory that came from $(pwd) for map volumes. So, I used docker-compose instead.

The docker-compose.yml file.

version: '3'
services:
  react-app:
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - "3000:3000"
    volumes:
      - /app/node_modules
      - .:/app
查看更多
▲ chillily
6楼-- · 2020-05-18 04:59

Replacing image: ${DOCKER_REGISTRY}notificationsapi with image:notificationsapi or image: ${docker_registry}notificationsapi in docker-compose.yml did solves the issue

file with error

  version: '3.4'

services:
  notifications.api:
    image: ${DOCKER_REGISTRY}notificationsapi
    build:
      context: .
      dockerfile: ../Notifications.Api/Dockerfile

file without error

version: '3.4'

services:
 notifications.api:
    image: ${docker_registry}notificationsapi
    build:
      context: .
      dockerfile: ../Notifications.Api/Dockerfile

So i think error was due to non lower case letters it had

查看更多
beautiful°
7楼-- · 2020-05-18 05:00

In my case, the image name defined in docker-compose.yml contained uppercase letters. The fact that the error message mentioned repository instead of image did not help describe the problem and it took a while to figure out.

查看更多
登录 后发表回答