Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 275
Anand Avatar asked Dec 08 '17 06:12

Anand


People also ask

How does Jenkins integrate with Docker host?

Go to Manage Jenkins -> Plugins -> Available and type “docker” into the field. Select “Docker plugin” and install it. Jenkins refers to the Docker plugin as a “cloud.” Click Manage Jenkins once again, and now click the Manage Clouds and Nodes button in the middle. Now click Configure Clouds on the left.

How do I connect Jenkins to Docker hub?

In Jenkins you have to add a new credential with your Docker Hub account details. Go to Credentials → Global → Add credentials and fill out the form with your username and password. Create your Jenkins pipeline.


1 Answers

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

like image 199
shaik47 Avatar answered Oct 24 '22 17:10

shaik47