Steps to reproduce:
- create a freestyle job that will be building a docker image
- fill in source details (any repo with a Dockerfile)
- add a Docker Builld and Publish step
- fill in a repository name (e.g. myimg)
- use a shortname of a custom registry in Docker registry URL field (e.g. https://myregistry:443/v1/
- save and run the job
Job succeeds, the image is tagged as myregistry:443/myimg and pushed OK.
Job fails, the image is tagged as myregistry/myimg which means docker push tries to push it to the public DockerHub registry (and fails as there are no credentials).
I suspect this is in DockerBuilder.Perform.getNameAndTag defined in https://github.com/jenkinsci/docker-build-publish-plugin/blob/master/src/main/java/com/cloudbees/dockerpublish/DockerBuilder.java#L272 or possibly even in DockerBuilder.getRepo. I'm not familiar with the code so wasn't sure what will be affected if that is changed.