docker-plugin: Cannot build docker images: "Could not get client"

Hi,

I am having some trouble building images. Every time I run the job I get the following error:

Docker Build
Docker Build: building image at path /var/lib/jenkins/jobs/docker_image_build/workspace/dockerfiles/Apache/base-jessie
ERROR: Build step failed with exception
java.lang.IllegalArgumentException: Could not get client because we could not find the cloud that the project was built on. What this build run on Docker?
    at org.apache.commons.lang.Validate.notNull(Validate.java:192)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.getClient(DockerBuilderPublisher.java:173)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.access$200(DockerBuilderPublisher.java:116)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run$1.invoke(DockerBuilderPublisher.java:246)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run$1.invoke(DockerBuilderPublisher.java:232)
    at hudson.FilePath.act(FilePath.java:990)
    at hudson.FilePath.act(FilePath.java:968)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.buildImage(DockerBuilderPublisher.java:232)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.run(DockerBuilderPublisher.java:189)
    at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher.perform(DockerBuilderPublisher.java:306)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Build step 'Build / Publish Docker Containers' marked build as failure
Finished: FAILURE

To elaborate some more, docker is running locally and a “cloud” is configured. I have no problem starting an already existing image via a job but building one for some reason fails.

There is also no option to specify a cloud in the “Build / Publish Docker Containers” build step.

The Cloud section from config.xml

<clouds>
    <com.nirima.jenkins.plugins.docker.DockerCloud plugin="docker-plugin@0.16.0">
      <name>docker</name>
      <templates>
        <com.nirima.jenkins.plugins.docker.DockerTemplate>
          <configVersion>2</configVersion>
          <labelString>jenkinsslave</labelString>
          <launcher class="com.nirima.jenkins.plugins.docker.launcher.DockerComputerSSHLauncher">
            <sshConnector plugin="ssh-slaves@1.10">
              <port>22</port>
              <credentialsId>64b21707-c8e9-4a8e-a0fc-345488070b2c</credentialsId>
              <jvmOptions></jvmOptions>
              <javaPath></javaPath>
              <maxNumRetries>0</maxNumRetries>
              <retryWaitTime>0</retryWaitTime>
            </sshConnector>
          </launcher>
          <remoteFsMapping></remoteFsMapping>
          <remoteFs>/home/jenkins</remoteFs>
          <instanceCap>1</instanceCap>
          <mode>NORMAL</mode>
          <retentionStrategy class="com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy">
            <idleMinutes>10</idleMinutes>
            <idleMinutes defined-in="com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy">10</idleMinutes>
          </retentionStrategy>
          <numExecutors>1</numExecutors>
          <dockerTemplateBase>
            <image>jenkinsslave</image>
            <dockerCommand></dockerCommand>
            <lxcConfString></lxcConfString>
            <hostname></hostname>
            <dnsHosts/>
            <volumes/>
            <volumesFrom2/>
            <environment/>
            <bindPorts></bindPorts>
            <bindAllPorts>false</bindAllPorts>
            <privileged>false</privileged>
            <tty>false</tty>
            <extraHosts class="java.util.Collections$UnmodifiableRandomAccessList" resolves-to="java.util.Collections$UnmodifiableList">
              <c class="list"/>
              <list reference="../c"/>
            </extraHosts>
          </dockerTemplateBase>
          <removeVolumes>false</removeVolumes>
          <pullStrategy>PULL_NEVER</pullStrategy>
        </com.nirima.jenkins.plugins.docker.DockerTemplate>
      </templates>
      <serverUrl>unix:///var/run/docker.sock</serverUrl>
      <connectTimeout>0</connectTimeout>
      <readTimeout>0</readTimeout>
      <credentialsId></credentialsId>
      <containerCap>100</containerCap>
    </com.nirima.jenkins.plugins.docker.DockerCloud>
  </clouds>

I am using the following versions:

Jenkins: 1.656
Docker plugin: 0.16.0   

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Having a full working example would be very helpful here, I think.

Even if I restrict the job to master it still gives the same error:

Could not get client because we could not find the cloud that the project was built on. What this build run on Docker?

You must not run JOB on MASTER.

java.lang.IllegalArgumentException: Could not get client because we could not find the cloud that the project was built on. What this build run on Docker? means that CMD tries extract docker client connection from running slave where build happens and it MUST be docker provisioned slave.