Closed savishy closed 8 years ago
To push image using Docker, I have several options:
Option 1
docker login [-u -p]
docker push savishy/tomcat-petclinic
This would work but not in an automated Jenkins container scenario. In a Jenkins container I don't have the docker
command.
Option 2
The second option: Use the Docker Build Steps plugin. The issue here is that I need to pre-load the credentials (in the form of credentials.xml) which does not seem to work across multiple Jenkins instances.
Option 3
The third option:
root@09fd175fdff4:/usr/share/jenkins/ref/plugins# curl -X POST http://172.17.0.1:2375/images/savishy/tomcat-petclinic/push
Where 172.17.0.1
is the IP of the Docker Host. 2375 is the port where Docker daemon is listening.
In this approach I need to feed in additional --header
parameters:
{"message":"Bad parameters and missing X-Registry-Auth: EOF"}
XRA=`echo "{\"username\": \"${USERNAME}\", \"password\": \"${PASSWORD}\", \"email\": \"${EMAIL_ADDRESS}\", \"serveraddress\" : \"${SERVER_ADDRESS}\"}" | base64 --wrap=0`
curl -v --request POST --header "X-Registry-Auth: $XRA"
Special characters such as !
and @
in the password have to be escaped obviously.
Option 4
Trying another plugin, Cloudbees Docker Publish. Any plugin will ultimately come back to the problem of autoloading credentials mentioned in Option 2.
The curl
approach works (at least it starts pushing). However it is finicky and depends on internet.
I frequently get any of the following errors:
{"errorDetail":{"message":"net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"},"error":"net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"}
{"errorDetail":{"message":"dial tcp: lookup auth.docker.io on 127.0.1.1:53: read udp 127.0.0.1:42997-\u003e127.0.1.1:53: i/o timeout"},"error":"dial tcp: lookup auth.docker.io on 127.0.1.1:53: read udp 127.0.0.1:42997-\u003e127.0.1.1:53: i/o timeout"}
It is possible that all these problems are because I use the official Jenkins docker image for building my Jenkins docker container.
I ran a quick experiment on Saturday and it shows I need to explore building the Jenkins image from scratch. (Issue #12 )
The curl -X POST
of the docker image works properly when Jenkins container is in AWS. Considering this issue fixed.
While working on #10 I am encountering the following issue