Skip to end of metadata
Go to start of metadata

Plugin Information

View docker-build-step on the plugin site for more information.

This plugin allows to add various Docker commands into your job as a build step

If you would like to use Docker for dynamics slave provisioning, you should check this plugin.

Plugin currently support following commands:

  • commit changes in specified container
  • create new container from image
  • create image from Dockerfile
  • create exec command
  • kill container(s)
  • pull image from a repository
  • push image to a repository
  • remove container(s)
  • remove all containers
  • restart container(s)
  • start container(s)
  • stop container(s)
  • stop all containers
  • start/stop all containers created from specified image
  • start exec command

Some commands also export build variables, so that you can easily use them in subsequent build steps.
Variables exported by create and start commands:

  • DOCKER_CONTAINER_IDS - IDs of created/started containers
  • DOCKER_IP_$HOSTNAME - IP of running container with hostname $HOSTNAME

When port binding in set up (in start command), following environment variables are exported:

  • DOCKER_HOST_BIND_PORTS - contains comma separated list of ports to which are bound docker container ports 
  • DOCKER_HOST_PORT_$SCHEMA_$PORT - which docker container port is bound to this port (e.g. DOCKER_HOST_PORT_TCP_80 would contain value 8080 in case that container port 8080 is bound to port 80 on host)
  • DOCKER_HOST_SOCKET_$SCHEMA_$PORT - host IP:PORT to which conatiner $PORT using $SCHEMA is bound. E.g. with following port binding, container TCP port is 8080 is bound to host port 80 on loopback and DOCKER_HOST_SOCKET_TCP_8080 will contain

Known limitations: Commands run without any issue only on master, on remote slaves command execution fails, see JENKINS-24071 for details.


You have to make sure that Docker service is running on slaves where you run the build. In Jenkins global configuration, you need to specify Docker REST API URL (typically somethig like and select build steps you'd like to perform in your job configuration.


Upcoming changes

Release 2.0 (2018-01-21)

  • Command executed remotely on slave (pull52)

Release 1.43 (2017-06-09)

  • Handle empty arguments in CreateImageCommand (pull49)

Release 1.42 (2017-05-22)

  • Bump docker-java version to 3.0.10 (pull48)

Release 1.41 (2017-03-30)

  • Added support for build-arg in Create image command (pull60)

Release 1.40 (2017-03-10)

Release 1.39 (2017-02-08)

  • Expanded tag parameter in Push image build step (pull53)

Release 1.38 (2017-01-18)

  • Updated Apache httpclient version (pull44)
  • Support for specifying Docker file name in Create image build step (pull51)

Release 1.37 (2017-01-05)

  • Upgrade to docker java 2.2.3 (pull41)
    BACKWARD INCOMPATIBLE CHANGE:  following options were moved (due to changes in underlying docker-java library) from StartConatinter command to CreateContainer command:
    • publishAllPorts
    • portBindings
    • links
    • bindMounts
    • privileged
  • Added several features (pull42)
    • support for SSL
    • always restart container policy
    • extra hosts option (list of hostnames added to /etc/hosts)
  • Wait for completion of some actions to make sure they succeeded (pull43)
  • Upgrade to docker java 3.0.6 (pull45)

Release 1.36 (2017-01-05)

  • broken release (as I forgot on INFRA-588)

Release 1.35 (2016-05-11)

Release 1.34 (2016-03-01)

  • Support the post-build action in a multi-configuration project (pull40)

Release 1.33 (2015-11-19)

  • Added force option to commands for container removal (pull39)

Release 1.32 (2015-10-30)

  • Added force option for tag command (pull38)
  • Improve description of config form fields (pull36) and display text (pull37)

Release 1.31 (2015-09-05)

  • Upgrade docker-commons to 1.2 (pull35)

Release 1.30 (2015-08-28)

  • Container command can take arguments (pull34)
  • Fixed NPE in CreateImageCommand (issue #20)

Release 1.29 (2015-08-14)

  • Added missing Jelly file for SaveImageCommand (pull24)

Release 1.28 (2015-07-24)

  • Added TagImageCommand (pull33)
  • Added configuration for RemoveImageCommand (pull33)

Release 1.27 (2015-07-15)

  • Added option to remove intermediate containers after a successful build to Create image command
  • Docker URL and version in global config can now contain environment variables

Release 1.26 (2015-06-26)

Release 1.25 (2015-06-05)

  • Added option for removing volumes when removing container (pull31)

Release 1.24 (2015-05-07)

  • Intorduced new command combining create and start exec commands (pull30)
  • Show in the build log stream response from Docker in start exec command (pull30)

Release 1.23 (2015-04-28)

  • Expanded env. variables in commit command (pull29)

Release 1.22 (2015-04-07)

  • Added possibility to capture container log - currently works only for containers with TTY disabled (pull28)
  • Added post build step to stop and remove Docker containers (pull27)
  • Built with JDK6 support - docker-java library rebuilt with JDK6 support (JENKINS-27821)

Release 1.21 (2015-03-11)

  • Added option for CPU and memory limits when creating container (pull26)
  • Host IP:PORT to which some container port is bound is now exported as DOCKER_HOST_SOCKET_$SCHEMA_$PORT (pull25)

Release 1.20 (2015-02-27)

  • Added exposed ports option to CreateContainerCommand (pull24)

Release 1.19 (2015-02-23)

  • Exec create and exec start commands
  • Fixed issue with authnetication (pull23)

Release 1.18 (2015-01-19)

  • Added option to ignore nonexistent containers IDs when removing the containers (pull8).

Release 1.17 (2015-01-07)

Release 1.16 (2014-12-05)

Release 1.15 (2014-12-04)

  • Jenkins plugins class loader is now passed into docker-java client
  • Allow "no-cache" option in Create Image step (JENKINS-25835)
  • Added option for links when creating a container
  • Added option for specifying links when starting a container (JENKINS-25796)
  • Option for specifying container name when created container

Release 1.14 (2014-11-25)

Release 1.13 (2014-11-06)

  • Multiple port bindings (pull17)
  • Upgrade to docker-java 0.10.3 (pull18)

Release 1.12 (2014-10-24)

Release 1.11 (2014-10-01)

  • Added EnvVars option in Create container command (pull14)
  • Fixed invalid version information in Docker URL (JENKINS-24551)

Release 1.10 (2014-09-19)

  • Upgrade to docker-java 0.10.0 (pull13)
  • Create image build step fails with Jenkins prior to 1.553 (JENKINS-24699) - requires Jenkins core 1.554.1 or higher

Release 1.9 (2014-08-21)

  • Added env. variables with port bindings (JENKINS-23704)
  • Execute Docker commands remotely on slaves (actually wasn't fixed, see JENKINS-24071)

Release 1.8 (2014-08-15)

  • Added more options for Start container command - publish all ports and privileged option (pull10)
  • Added option for Docker client version (JENKINS-24156)
  • Switch to Docker syntax for port binding, backward incompatible change, see JENKINS-23704 for details (pull7)

Release 1.7 (2014-08-06)

  • Removed placeholder text from index page (pull4)
  • Allow admin to save global config page even if Docker URL is empty (JENKINS-23733)
  • Added option for specifying port mapping when the container is started (JENKINS-23704)
  • Expand env. variables in "wait for ports" field (JENKINS-24043)
  • Don't use JDK7 methods (JENKINS-24041)
  • Command is optional on container creation (pull5)

Release 1.6 (2014-06-17)

Release 1.5 (2014-06-07)

  • Check, if Docker URL was provided and Docker client initialized (JENKINS-23342)
  • Validation button for Docker URL in global configuration (JENKINS-23343)

Release 1.4 (2014-05-28)

Release 1.3 (2014-05-21)

Release 1.2 (2014-04-06)

  • Improved logging during building image from Docker file (JENKINS-22083/pull2)
  • Wait for specified ports when starting containers (optional)

Release 1.1 (2014-03-06)

  • Start and stop all containers created from specified image
  • Pulling image from a repository
  • Commit changes in specified container
  • Create image from Dockerfile (pull1)

Release 1.0 (2014-02-17)

  • Initial release


  1. Very helpful but it lacks some documentation: We dont know the meaning of each field and the command that will be executed

  2. Did anyone manage to use the docker socket with this plugin?

    Using unix:///var/run/docker.sock as the Docker URL gives me Could not initialize class
    	at org.glassfish.jersey.client.ClientRuntime.invoke(
    	at org.glassfish.jersey.client.JerseyInvocation$
    	at org.glassfish.jersey.internal.Errors.process(
  3. How do I remove a container which I don't know its id?
    Could you please support DOCKER_CONTAINER_IDS as ouput of Stop Containter action?

  4. Hello

    This plugin...

    * lacks of documentation

    * have abscond error message (A NullPointerException is not very useful)

    * Doesn't have a tooltip icon for describing what it does. 

    What a waste of time. Disappointed

  5. Hi,

    Thank you for making this plugin. This is very useful when running jenkins itself from within a docker and need to use sibling docker for other builds.

    Are there any plans to support ECS repo via IAM role creds? Something like ?

  6. Is there a way to specify the shm-size during the build process? It doesn't look like it at the moment. I'm using version 1.43 at the moment.

  7. Hi,

    Does this plugin support pipelines?

  8. how to add the --name parameter in the plugin?

  9. How to set build path?