question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running Jenkins on Docker and using docker-plugin

See original GitHub issue

I’m running Jenkins on Docker using the official image from the Docker Hub, and I’m trying to use the docker-plugin to connect to containers running on the same Docker host as the Jenkins server.

Since the docker-plugin can’t yet connect to a unix socket, I’m running socat on the Jenkins container to proxy a local TCP socket to the volume-mounted /var/run/docker.sock. That means the Jenkins server connects to localhost:4243, but the real Docker host is on, say, 10.0.0.5.

When a new container is created, port 22 is exposed to 0.0.0.0:48349 (some random port), to which Jenkins then tries to connect. But the problem is that Jenkins is trying to connect to localhost:48349, and obviously failing since localhost for the Jenkins server is a different network than localhost for the Docker server.

I’d like to achieve two things, if possible:

  • Have Jenkins create the containers but not expose any ports outside of the container
  • Have Jenkins connect to the container’s IP directly, not through localhost or other settings, i.e., I want Jenkins to connect to (for example) 172.17.0.20:22 (which is why I don’t want it to expose any ports - there’s simply no need for it in my case)

Is this possible with any current version of the docker-plugin? I tried fiddling with a few settings but it doesn’t seem like it is possible to ignore the exposed port setting and https://github.com/jenkinsci/docker-plugin/pull/200 deals with a similar though different issue.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
KostyaShacommented, Jan 20, 2016

Works fine for me.

1reaction
KostyaShacommented, Jan 21, 2016

Just use api access without sockets, then everything should work fine. If ssh doesn’t work, then try jnlp launcher. That’s all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker - Jenkins Plugins
This plugin allows containers to be dynamically provisioned as Jenkins nodes using Docker. It is a Jenkins Cloud plugin for Docker. The aim...
Read more >
How to Configure Docker in Jenkins - phoenixNAP
Install Docker Plugin · 1. Select Manage Jenkins in the menu on the left side of the Jenkins dashboard. · 2. Click Manage...
Read more >
Continuous integration with Docker and Jenkins | InfoWorld
Go to Manage Jenkins -> Plugins -> Available and type “docker” into the field. Select “Docker plugin” and install it. Jenkins refers to...
Read more >
Docker tutorial : Build Docker images using Jenkins
Step #2 : Configure the plugins and start building Docker Images. · Once you are inside the Jenkins Dashboard, select Manage Jenkins on...
Read more >
How To Setup Docker Containers As Build Agents For Jenkins
Configure Jenkins Server With Docker Plugin. Step 1: Head over to Jenkins Dashboard –> Manage Jenkins –> Manage Plugins. Step 2: Under the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found