Running Jenkins on Docker and using docker-plugin
See original GitHub issueI’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:
- Created 8 years ago
- Comments:23 (12 by maintainers)
Works fine for me.
Just use api access without sockets, then everything should work fine. If ssh doesn’t work, then try jnlp launcher. That’s all.