Skip to end of metadata
Go to start of metadata

Plugin Information

View Docker on the plugin site for more information.

This plugin allows slaves to be dynamically provisioned using Docker.

Background

Docker plugin allows to use a docker host to dynamically provision build agents, run a single build, then tear-down agent.

Optionally, the container can be committed, so that (for example) manual QA could be performed by the container being imported into a local docker provider, and run from there.

Setup

A quick setup is :

- get a docker environment running

- follow the instructions for creating a docker image that can be used as a Jenkins Agent

Docker Environment

Follow the installation steps on docker.io.

If your host needs to allow connections from a jenkins instance hosted on a different machine, you will need to open up the TCP port. This can be achieved by editing the docker config file and setting (for example)

DOCKER_OPTS="-H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock"

The docker configuration file location will depend your system, but it is likely to be /etc/init/docker.conf, /etc/default/docker or /etc/default/docker.io)

Multiple Docker Hosts

If you want to use more than just a physical node to run containers, you can rely on Docker Swarm Standalone - docker engine swarm mode isn't yet supported.

Follow docker swarm standalone instruction and configure docker swarm API endpoint in Jenkins.

 

Jenkins Configuration

Docker plugin is a "Cloud" implementation. You'll need to edit Jenkins system configuration (Jenkins > Manage > System configuraiton) and add a new Cloud of type "Docker".

 

Configure Docker (or Swarm standalone) API URL with required credentials. A test button let you connection with API is well set.

Then configure Agent templates, assigning them labels you can use for your jobs to select the adequate template, and docker container to run

Creating a docker image

You need a docker image that can be used to run Jenkins agent runtime. Depending on the launch method you select, there's some prerequisites for the Docker image to be used :

Launch via SSH

  • sshd server and a JDK installed. You can just use jenkins/ssh-slave as a basis for a custom image.
  • a SSH key (based on unique Jenkins master instance identity) can be injected in container on startup, you don't need any credential set as long as you use standard openssl sshd. 

    For backward compatibility or non-standard sshd packaged in your docker image, you also have option to provide manually configured ssh credentials

Launch via JNLP

  • a JDK installed. You can just use jenkins/jnlp-slave as a basis for a custom image.
  • Jenkins master URL has to be reachable from container.
  • container will be configured automatically with agent's name and secret, so you don't need any special configuration of the container

Launch attached

  • a JDK installed. You can just use jenkins/slave as a basis for a custom image. 
  • Please note this mode is experimental at time writing.

 

To create a custom image and bundle your favorite tools, just create a Dockerfile with FROM to point to one of the jenkins/*-slave reference image, and install everything needed for your own usage

 
Dockerfile
FROM jenkins/ssh-slave
RUN apt-get update && apt-get install XXX
COPY your-favorite-tool-here

 

Note on ENTRYPOINT

Avoid overriding the docker command, as SSH Launcher relies on it.

You can use an Entrypoint to run some side service inside your build agent container before the agent runtime starts and establish a connexion. Just ensure your entrypoint eventually run the passed command :

exec "$@"

Configure plugin via Groovy script

Either automatically upon Jenkins post-initialization or through Jenkins script console. Example running locally, connecting to Docker service through unix///var/run/docker.sock and launching attached:

import com.nirima.jenkins.plugins.docker.DockerCloud
import com.nirima.jenkins.plugins.docker.DockerTemplate
import com.nirima.jenkins.plugins.docker.DockerTemplateBase
import com.nirima.jenkins.plugins.docker.launcher.AttachedDockerComputerLauncher
import io.jenkins.docker.connector.DockerComputerAttachConnector
import jenkins.model.Jenkins

// parameters
def dockerTemplateBaseParameters = [
  bindAllPorts:       false,
  bindPorts:          '',
  cpuShares:          null,
  dnsString:          '',
  dockerCommand:      '',
  environmentsString: '',
  extraHostsString:   '',
  hostname:           '',
  image:              'jenkinsci/slave:latest',
  macAddress:         '',
  memoryLimit:        null,
  memorySwap:         null,
  network:            '',
  privileged:         false,
  pullCredentialsId:  '',
  tty:                true,
  volumesFromString:  '',
  volumesString:      ''
]

def DockerTemplateParameters = [
  instanceCapStr: '4',
  labelString:    'docker.local.jenkins.slave',
  remoteFs:       ''
]

def dockerCloudParameters = [
  connectTimeout:   3,
  containerCapStr:  '4',
  credentialsId:    '',
  dockerHostname:   '',
  name:             'docker.local',
  readTimeout:      60,
  serverUrl:        'unix:///var/run/docker.sock',
  version:          ''
]

// https://github.com/jenkinsci/docker-plugin/blob/docker-plugin-1.1.2/src/main/java/com/nirima/jenkins/plugins/docker/DockerTemplateBase.java
DockerTemplateBase dockerTemplateBase = new DockerTemplateBase(
  dockerTemplateBaseParameters.image,
  dockerTemplateBaseParameters.pullCredentialsId,
  dockerTemplateBaseParameters.dnsString,
  dockerTemplateBaseParameters.network,
  dockerTemplateBaseParameters.dockerCommand,
  dockerTemplateBaseParameters.volumesString,
  dockerTemplateBaseParameters.volumesFromString,
  dockerTemplateBaseParameters.environmentsString,
  dockerTemplateBaseParameters.hostname,
  dockerTemplateBaseParameters.memoryLimit,
  dockerTemplateBaseParameters.memorySwap,
  dockerTemplateBaseParameters.cpuShares,
  dockerTemplateBaseParameters.bindPorts,
  dockerTemplateBaseParameters.bindAllPorts,
  dockerTemplateBaseParameters.privileged,
  dockerTemplateBaseParameters.tty,
  dockerTemplateBaseParameters.macAddress,
  dockerTemplateBaseParameters.extraHostsString
)

// https://github.com/jenkinsci/docker-plugin/blob/docker-plugin-1.1.2/src/main/java/com/nirima/jenkins/plugins/docker/DockerTemplate.java
DockerTemplate dockerTemplate = new DockerTemplate(
  dockerTemplateBase,
  new DockerComputerAttachConnector(),
  DockerTemplateParameters.labelString,
  DockerTemplateParameters.remoteFs,
  DockerTemplateParameters.instanceCapStr
)

// https://github.com/jenkinsci/docker-plugin/blob/docker-plugin-1.1.2/src/main/java/com/nirima/jenkins/plugins/docker/DockerCloud.java
DockerCloud dockerCloud = new DockerCloud(
  dockerCloudParameters.name,
  [dockerTemplate],
  dockerCloudParameters.serverUrl,
  dockerCloudParameters.containerCapStr,
  dockerCloudParameters.connectTimeout,
  dockerCloudParameters.readTimeout,
  dockerCloudParameters.credentialsId,
  dockerCloudParameters.version,
  dockerCloudParameters.dockerHostname
)

// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()

// add cloud configuration to Jenkins
jenkins.clouds.add(dockerCloud)

// save current Jenkins state to disk
jenkins.save()

Changelog

See https://github.com/jenkinsci/docker-plugin/blob/master/CHANGELOG.md

55 Comments

  1. in order for this plugin to work, you need the JClouds plugin installed.

    To Author: please add this information!

  2. Apparently you need Docker daemon to listen for tcp connection even if jenkins and docker run on the same machine - without opening up the TCP port jenkins and docker would not communicate.

    Also, I was trying to use the ready-made jenkins slave as suggested above, and I pulled the evarga/jenkins-slave image.

    However for me it does not work how it is.

    In the docker file it defines the user jenkins:jenkins. However trying to connect from Jenkins to your everga container image using username
    and password won't work: I needed to create an ssh key pair and modify the /etc/ssh/ssh_config file to point to the private key and /etc/ssh/sshd_config to point to the authorized_key file.

    Actually I believe that modifying the ssh server file should be enough (sshd_config), since here we are talking about an incoming ssh request. 
    Done this and committed the new evarga/jenkins-slave image, it started working. 

    My step by step: http://varmenise.tumblr.com/post/87976165063/docker-on-centos-jenkins

    1. port is also changed to 2375 since docker 1.0

    2. It's possible to use unix:///var/run/docker.sock as URL (https://github.com/docker-java/docker-java/issues/168).

      Additionaly, the jenkins user has to be a member of the docker group. And docker has to run on the local machine or when running jenkins as a container then the socket has to be passed in (https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/).

      1. I'm running Jenkins Master on Docker + slave containers on the same Docker.

        I tried passing in the socket. It worked for Jenkins to connect to docker deamon but then Docker Plugin was unable to find slave containers. I had to configure Docker deamon to allow incoming tcp connections. It didn't work for me by default. I used the platform-independent daemon.json file, which is located in /etc/docker/ on Linux by default.

        So, for configuring Daemon port to connect to, do the following:

        1. Set the following flag in the daemon.json file:

          {
              "hosts": ["tcp://0.0.0.0:2375"]
          }
          
          
        2. Restart Docker

           $ sudo systemctl restart docker

           

        More details https://docs.docker.com/engine/reference/commandline/dockerd/#extended-description

  3. Hi. Thanks for the plugin. As of 0.6 (I'm running 0.7 with Jenkins LTS 1.565.1) "Tag on Completion" was removed from the top-level configuration. The git comment with the change implies that the functionality just moved to the job configuration; make sense:

    "* cf32ca2 Nigel Magnay - Revise the post-completion options (tag, push, clean) - no longer part of the template, but part of the job. (9 weeks ago)"

    ... however, I think the new functionality is actually to "Commit on successful build". I cannot seem to replace the functionality of "Tag on Completion" which would tag and commit my container on failure as well. That way I could debug in the container when required. With this change, I cannot debug failures in the container. Am I missing something?

    Please let me know if you want me to open an Issue for this. And thanks again for the plugin.

    1. @smartmit: actually "Commit on successful build" works as "Tag on Completion".

      I tested it no matter the job is successful or not, the docker image will be saved with "<job name>:#<build number>", the tag "#<build number>" don't follow the docker tag naming rules since it contains "#"

      If "clean images" checkbox is enabled, the image will be removed.

      It seems we can't control to save images based on success/failure.

      feature in 0.7 version is mess

      • the configuration of "Docker container" in the job may not be put in the top (before parameter build)
      • Add a new template for all docker clouds may not be visible inside build step in job, it exists in system configuration
      • So far the docker container looks are stopped always, it is useless to have "stop container" task in Post job

      Also the document here is not up to date

  4. HI

    My Jenkins's version is Jenkins ver. 1.595 with docker plugin v0.8

    When I try to select cloud --> docker , nothing happen in web.

    But I find there are some erro log in /var/log/jenkins/jenkins.log , about My class is missing descriptor

    The following is the root cause

    Dec 26, 2014 12:12:13 PM hudson.ExpressionFactory2$JexlExpression evaluate
    WARNING: Caught exception evaluating: descriptor.getPropertyType(instance,field).itemTypeDescriptorOrDie in /$stapler/bound/333c1317-c818-4f69-9e8f-c616adfeb1af/render. Reason: java.lang.reflect.InvocationTargetException
    java.lang.reflect.InvocationTargetException

    ......

    Caused by: java.lang.AssertionError: class com.nirima.jenkins.plugins.docker.DockerTemplate is missing its descriptor in public final java.util.List com.nirima.jenkins.plugins.docker.DockerCloud.templates. See https://wiki.jenkins-ci.org/display/JENKINS/My+class+is+missing+descriptor
        at hudson.model.Descriptor$PropertyType.getItemTypeDescriptorOrDie(Descriptor.java:203)
        ... 128 more

    Dec 26, 2014 12:12:13 PM hudson.widgets.RenderOnDemandClosure$1 generateResponse
    WARNING: Failed to evaluate the template closure
    org.apache.commons.jelly.JellyTagException: jar:file:/var/lib/jenkins/plugins/docker-plugin/WEB-INF/lib/docker-plugin.jar!/com/nirima/jenkins/plugins/docker/DockerCloud/config.jelly:28:69: (file:/var/lib/jenkins/plugins/docker-plugin/WEB-INF/lib/docker-plugin.jar\!/com/nirima/jenkins/plugins/docker/DockerCloud/config.jelly:28:69:) <st:include> Error setting property 'class', exception - org.apache.commons.beanutils.ConversionException: No value specified for 'Class'
        at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:726)

    .....

    Caused by: java.lang.IllegalArgumentException: Error setting property 'class', exception - org.apache.commons.beanutils.ConversionException: No value specified for 'Class'
        at org.apache.commons.beanutils.ConvertingWrapDynaBean.set(ConvertingWrapDynaBean.java:74)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:265)
        ... 116 more
    Caused by: org.apache.commons.beanutils.ConversionException: No value specified for 'Class'
        at org.apache.commons.beanutils.converters.AbstractConverter.handleMissing(AbstractConverter.java:310)
        at org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:136)
        at org.apache.commons.beanutils.converters.ConverterFacade.convert(ConverterFacade.java:60)
        at org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1078)
        at org.apache.commons.beanutils.BeanUtilsBean.copyProperty(BeanUtilsBean.java:437)
        at org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java:160)
        at org.apache.commons.beanutils.ConvertingWrapDynaBean.set(ConvertingWrapDynaBean.java:67)
        ... 117 more

  5. I have been playing around with this plugin for week, it has some great features. 

    I like it fire up slaves on the fly, talking to apis in any server and host it in a cloud.

    But the deal breaker is a simple miss configuration or wrong images will result spawning so many slaves as to stun the master.

    Hopefully it can be resolve soon for this.

    1. j c

      Same here, I've created an issue on github.

  6. I tried running this plugin with no joy.

    Docker version 1.8.1

    Jenkins version 1.609

    I'm using the evarga/jenkins-slave image and followed the suggestions for updating ssh keys on the image.   I can run the image from the docker command line and ssh into the image. I've configured the system->cloud->docker and verified connectivity to docker using test connection.  I've configured the Jenkins project to use the container with the appropriate label.    When executing a build, Jenkins displays the message "pending---Waiting for next available executor" for the pending build job. I run docker ps and there is no container running.

    Anyone have some insight into getting this to work?

    1. Disregard,  I played around with the labels and it started working.  I believe I may have had a white space in the label.  Entering the labels for a second time,  in both system config and job config got things working.

  7. I am having some issues with this myself. Currently I am able to see the Images on my docker machine using the Jenkins GUI plug in but when I try to run a job on the correctly tagged image I get an error saying "(pending---All nodes of label ‘423262b670e4’ are offline". Not sure where the break down is but Jenkins clearly has access to the docker API as it is able to see all the images within Docker. I have tired many different types of lables on the images. I have also tired to use the docker.io/evarga/jenkins-slave image that is suggested as a preconfigured slave with no luck. I always get that error. Here is the out put from /var/log/messages 

    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.516929222-07:00" level=info msg="GET /containers/json?all=false&limit=-1&since=&before=&size=false"

    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.524794264-07:00" level=info msg="GET /containers/json?all=false&limit=-1&since=&before=&size=false"

    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.526443654-07:00" level=info msg="GET /images/json?filter=423262b670e4&all=true"

    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.536055583-07:00" level=info msg="POST /images/create?fromImage=423262b670e4"

    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.122418871-07:00" level=error msg="Error from V2 registry: Authentication is required."

    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.620184629-07:00" level=info msg="GET /images/423262b670e4/json"

    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.631906538-07:00" level=info msg="POST /containers/create"

    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.632159020-07:00" level=error msg="Handler for POST /containers/create returned error: json: cannot unmarshal string into Go value of type []string"

    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.632215872-07:00" level=error msg="HTTP Error" err="json: cannot unmarshal string into Go value of type []string" statusCode=500 

    Any help is greatly appreciated.

    Thanks!

    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.516929222-07:00" level=info msg="GET /containers/json?all=false&limit=-1&since=&before=&size=false"
    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.524794264-07:00" level=info msg="GET /containers/json?all=false&limit=-1&since=&before=&size=false"
    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.526443654-07:00" level=info msg="GET /images/json?filter=423262b670e4&all=true"
    Oct  1 12:57:48 sfo-docker-03 docker: time="2015-10-01T12:57:48.536055583-07:00" level=info msg="POST /images/create?fromImage=423262b670e4"
    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.122418871-07:00" level=error msg="Error from V2 registry: Authentication is required."
    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.620184629-07:00" level=info msg="GET /images/423262b670e4/json"
    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.631906538-07:00" level=info msg="POST /containers/create"
    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.632159020-07:00" level=error msg="Handler for POST /containers/create returned error: json: cannot unmarshal string into Go value of type []string"
    Oct  1 12:57:50 sfo-docker-03 docker: time="2015-10-01T12:57:50.632215872-07:00" level=error msg="HTTP Error" err="json: cannot unmarshal string into Go value of type []string" statusCode=500 

  8. Are there any plans to allow multiple entries to be defined in the Docker URL field? We run secondary masters in our Docker Swarm to enable redundancy, but with the Docker Plugin in its current form, we would have to manually update the URL if the primary master unexpectedly went offline. If that field accepted multiple entries, all of this would be handled automatically. 

  9. Hi! First I want to thank you for developing this plugin!

    My use case: Jenkins and Docker are running on different hosts and an firewall controls the whole network and blocks all connections by default (whitelist based). The connection between jenkins and docker server is secured with an TLS verification which runs fine after generating the PKCs key. It would be nice to have a note on the documentation about it, this ticket helped me figuring it out: https://github.com/jenkinsci/docker-plugin/issues/245

    I want to build my Jenkins Project on an Docker Image I created, so it must be started as a slave which is configured in "Manage Jenkins / Configure System / Cloud / Docker / Images", is that right? There only "Docker Templates" are available, where can i use an docker image that already exists?

    Also I have the problem that I don't have a clue (no documentation) about how the Jenkins Docker Plugin starts the Jenkins Slave Jar, because SSH connections on different ports are not available in our network..

  10. Hello,

    Would it be possible to provide an example, so as to clarify how to use the Remote FS Root Mapping field ?

    It says "Enables the ability to browse workspaces of jobs being built using docker containers. Specify the location on the Jenkins master where the job workspaces will be and map them from the images using volumes, network shares, etc."

    so I assume that the field must contain the location of a Jenkins Master local filesystem location. I gave it /var/lib/jenkins  but my workspaces are not available there.

    Maybe what the doc means by : "...map them from the images using volumes, network shares, etc" - means that it is up to me to use SMB ( or NFS or whatever ) to map :

    /var/lib/jenkins/myWorkspace 

    to my Docker host workspace folder ?

    1. Hi Brice,

       

      Did you figured this out?

       

      1. This "feature" has been removed from latest release, as it doesn't make any sense but for those running builds on same host as jenkins master with a local docker daemon.

  11. using 16.1, I got error: https protocol is not supported while using the http for Docker URL.

    downgrade back to 16.0, it worked.

    Not sure why 16.1 is complaining about  https protocol is not supported while using http.

  12. Does the Docker Plugin support connecting a Swarm using docker engine 1.12+ ?

    I cannot connect to the swarm as a new "Cloud" and am seeing this error:Caused by: shaded.org.apache.http.ProtocolException: The server failed to respond with a valid HTTP response

    I could successfully connect Swarm using docker engine 1.10:

    Version = swarm/1.2.4

    1. Which URL or params would you use to connect to a 1.10 swarm ? Which port and credentials ?

  13. I'm very sorry but I seemed to have accidentally edited this page's labels. Did not mean to. However, the label change does not show up in the page's history, so I'm not sure how to revert my own edit.

  14. I am using this plugin to run dynamic ssh jenkins slaves in a different server. I need to be able to use the -u argument in the docker run command so that I can mount workspace to host and write on host volumes without using the root user. any recommendations?

  15. We're using a private Docker repo that's unsigned. The Jenkins plugin seems unable to pull images from our repo. It works fine when pulling 'public' images (IE - ubuntu).

    I've ensured that our Docker host supports the unsigned repo (Ubuntu 16.04 - added repo to /etc/docker/daemon.json). I can manually pull the images from the repo to our Docker host and the Jenkins builds will run with the images run fine, it just can't seem to do the pull if the image doesn't exist.

    Example image name: dockerhost.ourcompany.com:5000/image:tag

    $docker pull dockerhost.ourcompany.com:5000/image:tag 

    works fine from the prompt.

    There's nothing in syslog to indicate what's going on. Any ideas? Do we need to do anything special for the plugin to support unsigned private repos?

    1. To add more data - It looks like specifically having the ":5000" on the tag causes a crash in the plugin (removing it allows the plugin to try and pull the image, but the image doesn't exist without the ":5000" in the name):

      Error in provisioning; template='DockerTemplate{configVersion=2, labelString='base', launcher=com.nirima.jenkins.plugins.docker.launcher.DockerComputerSSHLauncher@7735cda5, remoteFsMapping='/var/lib/jenkins', remoteFs='/home/jenkins', instanceCap=1, mode=NORMAL, retentionStrategy=com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy@54646eb4, numExecutors=1, dockerTemplateBase=DockerTemplateBase{image=dockerhose.ourcompany.com:5000/jenkins:base}, removeVolumes=false, pullStrategy=PULL_LATEST}' for cloud='Jenkins Master'
      java.lang.NullPointerException
        at com.nirima.jenkins.plugins.docker.utils.JenkinsUtils.makeAuthConfig(JenkinsUtils.java:173)
        at com.nirima.jenkins.plugins.docker.utils.JenkinsUtils.getAuthConfigFor(JenkinsUtils.java:165)
        at com.nirima.jenkins.plugins.docker.DockerCloud.pullImage(DockerCloud.java:369)
        at com.nirima.jenkins.plugins.docker.DockerCloud.provisionWithWait(DockerCloud.java:391)
        at com.nirima.jenkins.plugins.docker.DockerCloud.access$000(DockerCloud.java:64)
        at com.nirima.jenkins.plugins.docker.DockerCloud$1.call(DockerCloud.java:261)
        at com.nirima.jenkins.plugins.docker.DockerCloud$1.call(DockerCloud.java:258)
        at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        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)
      1. Nevermind - After RTFMing again - the plugin doesn't normally have functionality to pull the images from repos.

  16. Hi All,

    I am having 3 dockercloud running. If one of Dockercloud stops working(example docker goes down and takes 2 days to get it up), the jobs which were scheduled to run on other dockercloud won't start (jobs keep on waiting in queue).

    1. We are currently facing the same issues where we created 2 docker cloud environments for 2 physical docker nodes with the same label and a max capacity of 15 containers per node. When the first node reaches it's 15 containers the next job in line get's stuck in the queue waiting to clean up containers on the first node and never get's executed on the free 2nd node..

       

      Did you perhaps found a solution for this already? Is this normal behaviour and are we trying to have the plugin being too smart.

      1. Why do you use two cloud definitions for 2 physical nodes on your build cluster, and not a swarm manager (swarm standalone - swarm mode is not supported yet) ?

        Please also note wiki comments is the worst place to report issues (tongue) Please use JIRA or users-list

  17. Is the privileged option really working ? I'm unable to access to /dev/kvm from Jenkins . If I launch the image outside Jenkins with the privileged option, Jenkins user is able to see  /dev/kvm.

  18. Hello.
    This plugin is working great for me. There is however, one improvement that could be done. When Docker is launching new container it assigns unique ID that is also host name of the system running in Docker. I would like to use this host name (Container ID) as parameter to another plugin (VncViewer). I have found that there is DOCKER_CONTAINER_ID env. variable present, but it doesn't have this short ID that is present e.g. also when I list running containers with docker ps. Is there already Jenkins variable for this shorter ID present? If not, would it be possible to add it?
    BR, Krzysztof

  19. This wiki page is very out of date. It says:

    Latest Release 
    Latest Release Date 
    Required Core 
    Dependencies

    0.16.2 (archives) 
    Sep 13, 2016 

    1. Whoa. Why is my username showing as IRCbot Run by Kohsuke?

  20. Hi,

    Why "Keep this slave on-line as much as possible" retention strategy is gone since the last release?

    Thanks,

    Guy

    1. please join jenkins-users mailing list for questions.

      retention strategies have been whitelisted to only offer those who match the docker-agent use case : run agent in a container for a build, then throw it away.

  21. We've just updated from 0.16.2 to 1.0.4 and we've started seeing the following warning on the Jenkins front page:

    "SSH Host Key Verifiers are not configured for all SSH slaves on this Jenkins instance. This could leave these slaves open to man-in-the-middle attacks."

    We have a collection of bare-metal nodes, but they all of which have the "Host Key Verification Strategy" set, so we don't think that is the problem.  We also have a docker swarm that spins up containers as needed, and all "Docker Agent Templates" within that Docker cloud have "Connect method" set to "Connect with SSH".  Is this warning expected?  Is there a way to set the host verification strategy within the "Docker Agent Template"?

    1. Already fixed in 1.1.

      Please check issue tracker on github before posting, 

      and please don't use this wiki for assistance request, join jenkins-users for this purpose

  22. I'm using the plugin's "Build/Publish Docker Image" build step which starts successfully, and I can see in the logs that it starts processing the DockerFile I indicated. However, it keeps failing because it seems to be passing the workspace root directory as context for "docker build", but my Dockerfile is written such that the context is a subfolder under the repository root (a "src" folder), and I couldn't find a way to configure it.

    I took a look at the code and it seems that the plugin is always passing the Dockerfile's location as the build context:

    https://github.com/jenkinsci/docker-plugin/blob/5a2a123cd808a9c82d154cbcc22ef906a6a97907/src/main/java/com/nirima/jenkins/plugins/docker/builder/DockerBuilderPublisher.java#L409

    Are there any plans to allow the user to set a different context folder for the docker build?

    1. Why don't you just move your Dockerfile into this subfolder ?

      or use the plain docker CLI if you have some special needs ?

      also, better to ask on jenkins-users mailing list. Wiki isn't a support forum

      1. You're right, I'll check in the mailing list. But just to answer your question and for future reference, this repo has several projects and a Dockerfile for each, so it makes more sense to keep the Dockerfile in each project's subfolder. Having the plugin "tied" to a particular project structure feels a bit limiting. And about using plain docker CLI, that's the alternative I'm exploring now, but it required that I create a custom docker image for the Jenkins slaves with Docker installed. The fact that the plugin worked and actually started the docker build with a plain jenkins/ssh-slave image (asking the host to actually perform the docker build, obviously) made me a bit hopeful that I'd be able to pull this off with an OOTB ssh-slave image, but it seems I'll have to do a couple of extra things on top.

  23. Are there plans to support docker-compose?  IMO it would be incredible useful for companies that use compoase to create a common build environment using volumes/user/etc. like we do.  Currently we would love to use this plugin but we cannot because we must use compose so developers can run it locally too, so we are stuck doing it with bash in script{} blocks.

     

    1. This is partially covered by https://github.com/jenkinsci/docker-plugin/issues/549

      Main issue with docker-compose is this is a client-side tool, docker API doesn't know about this format, so we have to re-implement compose.yaml parsing and execution in plain java, supporting various versions.

  24. Hello guys!

    We deployed this plugin at the very beginning, and I cannot tell you since when, but we are now seeing many (our Jenkins crashes when >15k) threads (dockerjava-netty-*-*) created. They are all stuck in "sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)"

    1- I've quickly checked, and it seems that we cannot configure anything else than netty client?

    2- Can we configure something in order to avoid this?

    Let me know if you need some details about our setup and if you want me to create a bug...

    BR

  25. Hello!

    Short question:

    Is it possible to hide given labels for an image, so that autocomplete in the job-config-section will not show the label after the first letter ist pressed!?

    It is importent to me, that "non-admins" are not able to gain label-names!

     

    Thanks!

     

  26. Hello everyone. My objective/job is to run Jenkin's jobs in docker containers to see the result of these jobs in 'workspace' when a job is done. I have 2 issues here. the first is when the job is done, the container and the 'workspace' dies so I can not see the result. I put the 'workspace' into 'volume'. Now the 'workspace' doesn't die but it is still invisible for Jenkins. I have some ideas how to solve it but they are not really good. Can it be solved with the help of Docker-plugin? The second issue is that now I can add only all projects into 'volume' as I don't know how to configure it several times to separate the folders.

    1. Hello

       

             ...  I put the 'workspace' into 'volume'. Now the 'workspace' doesn't die but it is still invisible for Jenkins....

      Yes, of course! Because every started container is one unique Slave for the Jenkins. At the end of the build the container (which is also a complete slave) will be destroyed. So for Jenkins there is nothing he can look at.

       

             ... Can it be solved with the help of Docker-plugin?...

      I guess no. Because there is no problem. To save artefacts after the build, there are thousands ways to reach this. (save artefacts in nexus, use "archive arctefacts" from jenkins, copy via ssh, and so on ....)


            ... The second issue is that now I can add only all projects into 'volume' as I don't know how to configure it several times to separate the folders...

      Dont do that. This is a breach to the design! One main-purpose for using docker for builds is, to have a clean environment for each build!

       

      regards

      JekO

      1. Thanks for the answer. Why can not I use such environment variables in "volume"? 

  27. Is there any way to upgrade the docker version in the plugin? I want to use the multi stage builds of docker which is available on 17.05 + versions. Current version of docker is 17.03.

  28. Hello Folks,

    I am running into the same issue where I can't browse the workspace from Jenkins after building in a  docker container.

    Both Docker and Jenkins are running on the same host for now.

    Ubuntu 16.04

    Jenkins 2.89.4

    Docker 1.1.3

    Any help  on this issue would be greatly appreciated.

    Thanks

    1. Wiki is not a support forum, join jenkins-users mailing list.

      You can't browse workspace as workspace is attached to an agent and docker agent is removed after build completion. Just Archive artifacts.

  29. Thanks  for the information Nicolas,

    Will move to  jenkins-users for future questions

  30. I put this here in case it may save some time to someone:

    In the "container settings", the "Port bindings" field has not exactly the same effect than the "-p" option.

    Unlike the "-p" option of docker run, here you can't bind a port that is not exposed.

  31. include a option --no-cache for build dockerfile