Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker - Restrictions regarding naming image

Tags:

docker

image

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?

like image 449
drorbr Avatar asked Mar 29 '17 10:03

drorbr


People also ask

What is the naming convention of docker image?

Description. An image name is made up of slash-separated name components, optionally prefixed by a registry hostname. The hostname must comply with standard DNS rules, but may not contain underscores. If a hostname is present, it may optionally be followed by a port number in the format :8080 .

Can two docker images have the same name?

Multiple tags may refer to the same image. If you reassign a tag that is already used, then the original image will lose the tag, but will continue to exist (it will still be accessible by its image ID, and other tags might refer to it).

Is there any specific naming convention for the custom container?

The name can contain uppercase letters, lowercase letters, numbers, and underscores (_). The name must be from 1 to 255 characters long. Names are case sensitive. For example, you can have a container named myContainer and a folder named mycontainer because those names are unique.

Can we assign name to your container in docker?

When a container is created using Docker, Docker provides a way to name the container using the the --name <container_name> flag. However, if no name is provided by the user while creating/running a Docker container, Docker automatically assigns the container a name.


1 Answers

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...]
like image 69
BMitch Avatar answered Nov 27 '22 12:11

BMitch