microsoft / VSTS-Docker-Preview

Preview repo for Docker extension
16 stars 8 forks source link

Repository names with uppercase letters break Docker tasks #10

Open KrishnaAdityaB opened 7 years ago

KrishnaAdityaB commented 7 years ago

Copied from https://github.com/Microsoft/vsts-tasks/issues/2988

If the name of the repository has an uppercase letter and the "Image Name" field in the task settings is left default as ($(Build.Repository.Name):$(Build.BuildId), the Docker task fails since Docker fails if the repository name is not all lowercase.
2016-10-31T21:32:10.1156180Z ##[section]Starting: Build an image
2016-10-31T21:32:10.4071990Z 4de0abcf-e253-4b34-b9c7-eb5cdfdd0c7a exists true
2016-10-31T21:32:10.4099210Z [command]/usr/bin/docker login -u ******** -p ******** ********
2016-10-31T21:32:11.0489340Z Login Succeeded
2016-10-31T21:32:11.0554530Z [command]/usr/bin/docker build -f /home/vstsbuild/vsts-agent/_work/1/s/Dockerfile -t OguzPastirmaci/vsts-dockerhub-dockercloud-azure:276 /home/vstsbuild/vsts-agent/_work/1/s
2016-10-31T21:32:11.0704490Z invalid argument "OguzPastirmaci/vsts-dockerhub-dockercloud-azure:276" for t: invalid reference format: repository name must be lowercase
2016-10-31T21:32:11.0712890Z See 'docker build --help'.
2016-10-31T21:32:11.0775540Z [command]/usr/bin/docker logout ********
2016-10-31T21:32:11.0882480Z Remove login credentials for ********
2016-10-31T21:32:11.0937030Z ##[error]/usr/bin/docker failed with return code: 1
2016-10-31T21:32:11.1322530Z ##[section]Finishing: Build an image
stepro commented 7 years ago

We should decide in general whether we want to be sanitizing values of variables so that they meet the naming requirements for images, tags, etc. The current decision was to not do anything since it's more transparent, but that does mean that the default settings don't necessarily always work.

brienRosenquist commented 7 years ago

I also encountered this error. Workaround was to lowercase the $(Build.Repository.Name) variable. I used the Transform Value task found in the Market Place.

okke-formsma commented 6 years ago

I'm also running into this issue. I see three possible solutions:

  1. Always lowercase the entire build name, and document this in the info balloon [?]
  2. Introduce a way to execute string functions $(Build.Repository.Name):$(Build.BuildId) => $(Build.Repository.Name.Lowercase):$(Build.BuildId.Lowercase)
  3. Just insert the repository name here as default, such as "myrepository:$(Build.BuildId)"
stepro commented 6 years ago

The rules surrounding naming requirements for Docker images and tags are rather complicated. Just lower casing will work for many cases but not all. @KrishnaAdityaB, has there been any effort yet to address this issue? I would suggest that we accept names as is and perform sanitization into valid image names and tags. If it helps, I can dig up the specifics regarding naming (the precise rules aren't documented anywhere, I had to discover them in the Docker code base).

KrishnaAdityaB commented 6 years ago

Adding @jikuma who has been working on this task