How to find “Docker Host URI” to be used in Jenkins “Docker Plugin”?

天涯浪子 提交于 2019-12-10 03:47:01

问题


Is there any command which we can run and find out the "Docker Host URI"? I found some of related questions but didn't get it exactly.


回答1:


Yes this is the docker host uri

tcp://127.0.0.1:2375

But before that you need to add this DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"

In /etc/default/docker at the end of file, then restart the docker.onec restarted docker.sock will run in 2375 and add this tcp://127.0.0.1:2375 in Jenkins




回答2:


The other option would be to enter Docker Host URI "unix: ///var/run/docker.sock", it worked for me, I hope that it is also.




回答3:


Jenkins Docker Plugin Configuration when running jenkins as container

1) First Install Docker Plugin

2) Go to Manage Jenkins -> System Configuration -> Scroll down to botton -> Add Cloud -> Docker

3) If you are running jenkins as container, in the docker host uri field you have to enter unix or tcp address of the docker host. But since you are running jenkins as container, the container cant reach docker host unix port

4) So we have to run another container that can mediate between docker host and jenkins container. It will publich docker host's unix port as its tcp port. Follow the instructions to create socat container https://hub.docker.com/r/alpine/socat/

5)After the creating socat container, you can go back the docker configuration in jenkins and enter tcp://socat-container-ip:2375

6) Test Connection should succeed now



来源:https://stackoverflow.com/questions/47709208/how-to-find-docker-host-uri-to-be-used-in-jenkins-docker-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!