Skip to content

Instantly share code, notes, and snippets.

@scottrigby
Created September 6, 2019 14:22
Show Gist options
  • Save scottrigby/795972bb7fe382f4dbafa1e870e7f13b to your computer and use it in GitHub Desktop.
Save scottrigby/795972bb7fe382f4dbafa1e870e7f13b to your computer and use it in GitHub Desktop.
git docker tag formats

git docker tag formats

git tags and Docker tag formats don't fully overlap:

Fun test:

# Init temp git repo
$ cd `mktemp -d` && git init && git commit --allow-empty --allow-empty-message -m ''

# Get image ID from a tiny Docker image (240k): 
$ docker pull k8s.gcr.io/pause:latest
$ docker images k8s.gcr.io/pause:latest --format="{{.ID}}"
350b164e7ae1

# Add git tags not suitable for Docker
$ GIT_TAGS=(+foo Foo _foo foo+ foo+bar foo- foo_ foo___bar)
$ for t in ${GIT_TAGS[@]}; do git tag $t; done && git tag
+foo
Foo
_foo
foo+
foo+bar
foo-
foo_
foo___bar

# Watch them fail with docker tag
$ for t in ${GIT_TAGS[@]}; do docker tag 350b164e7ae1 $t; done
Error parsing reference: "+foo" is not a valid repository/tag: invalid reference format
Error parsing reference: "Foo" is not a valid repository/tag: invalid reference format: repository name must be lowercase
Error parsing reference: "_foo" is not a valid repository/tag: invalid reference format
Error parsing reference: "foo+" is not a valid repository/tag: invalid reference format
Error parsing reference: "foo+bar" is not a valid repository/tag: invalid reference format
Error parsing reference: "foo-" is not a valid repository/tag: invalid reference format
Error parsing reference: "foo_" is not a valid repository/tag: invalid reference format
Error parsing reference: "foo___bar" is not a valid repository/tag: invalid reference format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment