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.

Cannot build docker images: "Could not get client"

See original GitHub issue

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   

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
timstoopcommented, Apr 15, 2016

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

2reactions
KostyaShacommented, Aug 24, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't build docker image from Dockerfile - Stack Overflow
The error that you get is a generic one and results from a failed sanity check inside the Docker client code that can...
Read more >
Troubleshoot Docker Engine installation
Unable to connect to the Docker daemon​​ This error may indicate: The Docker daemon isn't running on your system. Start the daemon and...
Read more >
Building your Docker Image | Runnable Docker Guides
Detailed steps to build your Docker image and troubleshoot errors encountered during builds with Ruby on Rails applications.
Read more >
Pulling and Pushing Images in the Docker Client - Harbor docs
You cannot pull an unsigned image if you have enabled content trust. Pushing Images. Before you can push an image to Harbor, you...
Read more >
Troubleshooting AWS CodeBuild
This happens even if your related build image's Dockerfile sets the USER ... If the user does not have write access, the build...
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