I recently developed a Jenkins pipeline that does build and push for multiple projects. Now, I need to pull the built images to a specific server. As in, suppose Server 'A' is my build server and server 'B' is where I need to pull the build images to. I know I can go to Server B and execute docker pull from Docker hub. But is there a way I can automate this process of pulling the built images to a specific server in the same Jenkins Pipeline? or is there any feasible way to achieve this?
Asked
Active
Viewed 424 times
1
-
You might want to check this documentation "How to use your own Registry" on Docker: https://blog.docker.com/2013/07/how-to-use-your-own-registry/ then you can add the proper tag and push into it. – K F Aug 19 '19 at 03:41
-
I hope you meant "How to docker push to a specific server" ... – Rafaf Tahsin Aug 19 '19 at 03:51
-
I hope this might help you - https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository – Rafaf Tahsin Aug 19 '19 at 03:53
-
Yes could you please clarify whether this is pushing to a specific registry, pulling from a specific registry, or using a specific server, as the wording in the question seems midway between the three. – Matthew Schuchard Aug 19 '19 at 15:26
-
I would like to push the built images to docker hub and then pull the images to another server all from one Jenkins script. – mounika Aug 23 '19 at 04:53
1 Answers
0
You can include below commands on Jenkins pipeline steps section to run docker pull on remote server.
docker.withServer('tcp://<B Server>:2375', '') {
dockerImage.pull("<Image Name>")
}

Subramanian Manickam
- 1,199
- 7
- 9
-
1I tried your suggestion and encountered an error saying "no route to host". It clearly indicates that there is no route from my build server to my target server. Usually we do tunneling on target server if we want to run Jenkins on that. Is there a way we can include this tunneling in Jenkins script ? or do we need to open a route from my build server to target server? – mounika Aug 23 '19 at 04:52