Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43294

Searching for docker binary is only done on master executor

      If docker is not installed in the master executor, Jenkins doesn't try to run docker on other executors.

      I run Jenkins from a docker image, and of course I don't have docker in that image. I've limited the below job to run only on executors that have docker installed. I've also configured the plugin globally to fetch the latest docker.

       

      However, I still get the below error:

       

      Creating a Container slave to host hudson.model.FreeStyleProject@1722bec6[CMake/Build_Foo_Linux]#3
      Apr 03, 2017 12:09:51 PM SEVERE it.dockins.dockerslaves.ProvisionQueueListener onEnterBuildable
      Failure to create Docker Slave java.io.IOException: Cannot run program "docker": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.<init>(Proc.java:243) at hudson.Proc$LocalProc.<init>(Proc.java:212) at hudson.Launcher$LocalLauncher.launch(Launcher.java:815) at hudson.Launcher$ProcStarter.start(Launcher.java:381) at hudson.Launcher$ProcStarter.join(Launcher.java:388) at it.dockins.dockerslaves.drivers.CliDockerDriver.serverVersion(CliDockerDriver.java:448) at it.dockins.dockerslaves.drivers.CliDockerDriver.<init>(CliDockerDriver.java:78) at it.dockins.dockerslaves.drivers.PlainDockerAPIDockerDriverFactory.forJob(PlainDockerAPIDockerDriverFactory.java:43) at it.dockins.dockerslaves.DefaultDockerProvisionerFactory.createProvisionerForClassicJob(DefaultDockerProvisionerFactory.java:95) at it.dockins.dockerslaves.DockerSlaves.createStandardJobProvisionerFactory(DockerSlaves.java:101) at it.dockins.dockerslaves.ProvisionQueueListener.prepareExecutorFor(ProvisionQueueListener.java:93) at it.dockins.dockerslaves.ProvisionQueueListener.onEnterBuildable(ProvisionQueueListener.java:62) at hudson.model.Queue$BuildableItem.enter(Queue.java:2522) at hudson.model.Queue$BuildableRunnable.run(Queue.java:2826) at hudson.model.Queue.maintain(Queue.java:1474) at hudson.model.Queue$MaintainTask.doRun(Queue.java:2710) at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:50) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:248) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 24 more

          [JENKINS-43294] Searching for docker binary is only done on master executor

          The real problem seems to be that docker is always run on the master. I have the same problem with a Pipeline job; a dockerNode command within a node block still runs docker on the master instead of the specified node.

          Michael Mrozek added a comment - The real problem seems to be that docker is always run on the master. I have the same problem with a Pipeline job; a dockerNode  command within a node block still runs docker on the master instead of the specified node.

          We're facing the same issue. For policy reasons, we cannot have docker binary installed on Jenkins master machine.

          I'm wondering if adding an alternative to CliDockerDriver (a pure-Java client instead of relying on the cli "docker" command) is something that makes sense and would completely solve the issue? The client that looks to meet the requirement is this: https://github.com/spotify/docker-client

          ndeloof - is this something you're looking into? Does it make sense to me to try to do this from scratch and contribute?

          Piotr Paczyński added a comment - We're facing the same issue. For policy reasons, we cannot have docker binary installed on Jenkins master machine. I'm wondering if adding an alternative to CliDockerDriver (a pure-Java client instead of relying on the cli "docker" command) is something that makes sense and would completely solve the issue? The client that looks to meet the requirement is this:  https://github.com/spotify/docker-client ndeloof - is this something you're looking into? Does it make sense to me to try to do this from scratch and contribute?

          Ovidiu-Florin Bogdan added a comment - - edited

          I've found that you can easily work around this bug by using the pipeline plugin, and using the `docker.image("some image").inside {}` function. Just place that inside the proper `node('some label'){}` and it will run on the desired node.

          This is after all a groovy script, so I belive you can also use it without a pipeline per say. I hope this helps.

          Ovidiu-Florin Bogdan added a comment - - edited I've found that you can easily work around this bug by using the pipeline plugin, and using the `docker.image("some image").inside {}` function. Just place that inside the proper `node('some label'){}` and it will run on the desired node. This is after all a groovy script, so I belive you can also use it without a pipeline per say. I hope this helps.

          docker-slaves-plugin uses docker CLI on master to create master -> agent communication channel, this is by design.

          Could switch to some java client library for Docker API at some point, but will still need to docker API endpoint set on master.

          Nicolas De Loof added a comment - docker-slaves-plugin uses docker CLI on master to create master -> agent communication channel, this is by design. Could switch to some java client library for Docker API at some point, but will still need to docker API endpoint set on master.

            ndeloof Nicolas De Loof
            ovidiub13 Ovidiu-Florin Bogdan
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: