Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable Docker containers launched by Jenkins to access certain ports on 127.0.0.1? #1115

Open
ohMyJava opened this issue Nov 9, 2024 · 3 comments

Comments

@ohMyJava
Copy link

ohMyJava commented Nov 9, 2024

Jenkins and plugins versions report

Jenkins Version: 2.450
docker plugin version: 1.6.2

What Operating System are you using (both controller, and any agents involved in the problem)?

Jenkins deployed in Docker container on Linux host

Reproduction steps

Fill in the host option in the container configuration, and NPE will be prompted.
Is there any way to allow Docker to access port 127.0.0.1 without configuring the host?

Expected Results

Enable Docker to access port 127.0.0.1

Actual Results

Unable to access port 127.0.0.1

Anything else?

No response

Are you interested in contributing a fix?

No response

@MarkEWaite
Copy link
Contributor

I can't duplicate the problem that you are describing. I opened the cloud configuration on Jenkins 2.479.1 and in the Docker Agent Templates section I expanded the Container settings and entered as Hostname the value of the host where I run the Docker listener. No null pointer exception was reported. I'm running Docker plugin 1.7.0.

Does the same failure occur with Docker plugin 1.7.0 on a recent Jenkins version like 2.484?

@ohMyJava
Copy link
Author

ohMyJava commented Nov 11, 2024

Thank you for your response.
When I follow the following steps: Define a Docker template ->Container settings ->Network Input Area
When entering host in the input box of Network configuration, NPE will be prompted
Image

Error in provisioning; template='DockerTemplate{configVersion=2, labelString='f3646f65-8c16-449b-9f97-75c86e9768d3', connector=DockerComputerSSHConnector{sshKeyStrategy=InjectSSHKey{user='root'}, port=22, javaPath='/home/tools/java/jdk-11/bin/java'}, remoteFs='/home', instanceCap=1, mode=EXCLUSIVE, retentionStrategy=com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy@29, dockerTemplateBase=DockerTemplateBase{image='a17sw/test_curl:ver1', dnsHosts=[host], network'='host', bindAllPorts=false, cpuPeriod=0, cpuQuota=0, privileged=true, tty=false}, removeVolumes=false, stopTimeout=10, pullStrategy=PULL_NEVER, pullTimeout=0, disabled=BySystem,0 ms,4 min 59 sec,Template provisioning failed.}' for cloud='10.12.16.119'
java.lang.NullPointerException
at java.base/java.util.Arrays.stream(Arrays.java:5614)
at java.base/java.util.stream.Stream.of(Stream.java:1188)
at io.jenkins.docker.connector.DockerComputerSSHConnector.getBindingForPort(DockerComputerSSHConnector.java:387)
at io.jenkins.docker.connector.DockerComputerSSHConnector.createLauncher(DockerComputerSSHConnector.java:333)
at io.jenkins.docker.connector.DockerComputerConnector.createLauncher(DockerComputerConnector.java:187)
at com.nirima.jenkins.plugins.docker.DockerTemplate.doProvisionNode(DockerTemplate.java:758)
at com.nirima.jenkins.plugins.docker.DockerTemplate.provisionNode(DockerTemplate.java:686)
at com.nirima.jenkins.plugins.docker.DockerCloud$1.run(DockerCloud.java:414)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

Nov 11, 2024 3:01:26 PM WARNING jenkins.util.ErrorLoggingExecutorService lambda$wrap$0
null
java.lang.NullPointerException
at java.base/java.util.Arrays.stream(Arrays.java:5614)
at java.base/java.util.stream.Stream.of(Stream.java:1188)
at io.jenkins.docker.connector.DockerComputerSSHConnector.getBindingForPort(DockerComputerSSHConnector.java:387)
at io.jenkins.docker.connector.DockerComputerSSHConnector.createLauncher(DockerComputerSSHConnector.java:333)
at io.jenkins.docker.connector.DockerComputerConnector.createLauncher(DockerComputerConnector.java:187)
at com.nirima.jenkins.plugins.docker.DockerTemplate.doProvisionNode(DockerTemplate.java:758)
at com.nirima.jenkins.plugins.docker.DockerTemplate.provisionNode(DockerTemplate.java:686)
at com.nirima.jenkins.plugins.docker.DockerCloud$1.run(DockerCloud.java:414)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

@MarkEWaite
Copy link
Contributor

I can't duplicate that failure in my environment. I open the configuration page for my cloud agents, click the "Docker Agent Templates" button and expand the "Container settings". Then I enter "host" in the Network field and save it. No null pointer exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants