22

I have questions regarding restrictions about naming images. I search online and saw different issue and answers.

which special characters are not allowed in docker image name? (e.g. '*', '$', ',', '_' ...) Is it possible to use uppercase char for image name?

drorbr
  • 221
  • 1
  • 2
  • 4

2 Answers2

14

This documentation describes the rules for the docker image name and tag: https://docs.docker.com/engine/reference/commandline/tag/#extended-description

Name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.

A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.

wisbucky
  • 33,218
  • 10
  • 150
  • 101
11

From https://github.com/docker/distribution/blob/master/reference/regexp.go:

// nameComponentRegexp restricts registry path component names to start
// with at least one letter or number, with following parts able to be
// separated by one period, one or two underscore and multiple dashes.

This applies to the image name itself.

  • The regex for the letters is all lower case, no upper case letters.
  • You can include a hostname and an optional port number after a colon at the very beginning.
  • You can include a path between the hostname and image name with slashes /, and each element of the path has the same restrictions as the image name itself.
  • After the image name, you can append a tag after a colon or a digest after an @.

Expressed with the common bracketed notation:

[somehost.com[:1234]][/some-path/to/the]image-name[:myTag1.2.3]
[somehost.com[:1234]][/some-path/to/the]image-name[@ca468b84b84846e84...]
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Hi, so things like `host.com/a/b/c/d/e:1.0` is acceptable (with extra slashes)? I am afraid of whether some other tools will reject it or fail secretly? Thanks very much (Details: https://stackoverflow.com/questions/64513122) – ch271828n Oct 24 '20 at 12:21