Custom Docker Repository URL for Artifactory and Jenkins
I’m trying to get the Docker Build and Publish plugin working on our Jenkins instance. The Docker image is getting built correctly, but I’m having issues with getting this image pushed to our Artifactory Docker Repository.
When I look in the logs for the build, it fails to upload the Docker image, but the url looks like https://instance.company.com/test-docker-build. Here is the output from the log:
[workspace] $ docker push instance.company.com/test-docker-build:test The push refers to a repository [instance.company.com/test-docker-build] (len: 1) Sending image list Error: Status 405 trying to push repository test-docker-build: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>405 Method Not Allowed</title>\n</head><body>\n<h1>Method Not Allowed</h1>\n<p>The requested method PUT is not allowed for the URL /v1/repositories/test-docker-build/.</p>\n</body></html>\n" Build step 'Docker Build and Publish' marked build as failure Finished: FAILURE
I am assuming that it is failing because the repository URL is incorrect. I have also tried logging into the backend and pushing via the command line with the correct repository URL and that doesn’t seem to work either.
My main question is: does docker not like the URL structure since it uses the ‘/’ to denote user/image name? I.E. would this work if the url didn’t include the /artifactory?
Any ideas would be greatly appreciated!
One Solution collect form web for “Custom Docker Repository URL for Artifactory and Jenkins”
The response you’re getting back looks like something a reverse proxy would return (nginx\apache), not Artifactory – did you follow the instructions on how to set up a Reverse Proxy with Artifactory?
Usually you would need to:
- set up the reverse proxy for docker usage correctly
- either get a certificate for company.com and use it in the proxy or set up Artifactory as an insecure registry (beware of this – should not be used in production)
Once you did these you will reference the Artifactory instance as instance.company.com no need for /artifactory or anything else.
The url you posted is what the reverse proxy should use when directing to Artifactory (i.e. instance.company.com/artifactory/api/docker/test-docker-build/v2)
Then usage would look like
docker push instance.company.com/myImage:myTag