Child pages
  • CloudBees Docker Build and Publish plugin
Skip to end of metadata
Go to start of metadata

Plugin Information

View CloudBees Docker Build and Publish on the plugin site for more information.

This plugin provides the ability to build projects with a Dockerfile, and publish the resultant tagged image (repo) to the docker registry.  Docs are here.

If you want to build and push your Docker based project to the docker registry (including private repos), then you are in luck!

This is an early version - build @michaelneale of @cloudbees  - ask me if you have questions.

Features:

  • Only a Dockerfile needed to build your project
  • Publish to docker index/registry - INCLUDING PRIVATE REPOS/IMAGES
  • nocache option (for rebuild of all Dockerfile steps)
  • publish option
  • manage registry credentials for private and public repos
  • tag the image built - use any Jenkins env. variables.

Dockerfile as buildfile

A Dockerfile is a convenient way to express build instructions. This plugin will use the Dockerfile in the workspace (possibly previously checked out from git) and will invoke docker build to create the Docker image. The result can be automatically uploaded to the Docker Registry or a private registry.

As the Beatles song, all you need is Dockerfile, and love. If you have a Dockerfile in the root of your project, then no further configuration is needed.

How to use

Warning: the instructions below seem to cover the 0.x version of the plugin. Current documentation is here.

Firstly, ensure you have docker running (if you are running with a slave, ensure the slave can run docker) - and that Jenkins can run docker commands.

Setup a build of any type - with a CloudBees Docker Build and Publish build step. You can use the example under src/test/example to build a very simple busybox based image, and push it to jenkinsci/docker-build-and-publish-example.

The usual Docker build caching mechanism applies - and you can choose to publish, or not, the resultant image, configured under Advanced options.

Builds will be decorated with the repository name (and tag) of the build images:

You can supply multiple tags for an image separated by commas. The latest tag is automatically applied to image - if you do not want this check the Do not tag this build as latest checkbox.

Why use a Dockerfile

Defining your build as a Dockerfile means that it will run in a consistent linux environment, no matter where the build is run. You also end up with an image (in a repository, possibly pushed to a registry) that can then be deployed - the exact same image you built.

Dockerfiles can also help speed up builds. If there has been no change relative to a build instruction in the Dockerfile - then a cached version of that portion of the build can be used (this is a fundamental feature of docker)

More info

See more on the GitHub readme:

github.com

6 Comments

  1. Hi,

    Would there be a way to connect to another registry than index.docker.io ?

    I have a private registry in my company, and can't seem to find a way of publishing my images to it using this plugin.Would appreciate any help!

  2. Is this plugin still active? It's not showing up inside of Jenkin's Plugin Manager.

  3. I'm having trouble pushing the image to a private repo on docker hub - credential problem. For the life of me, I can't find where this dialog is in Jenkins:

    The docker login requires the -e argument and I can't pick a credential that has user,email,pw. Am I missing something? 

    Thanks

    1. I too am in the same situation. I just can't find where this configuration UI is in.

  4. Hi,

    Directly use this plugin in Jenkins job, I had no problem to build and push out image.

    But when tried it together with "CloudBees Docker Custom Build Environment Plugin" or other "Build Step" as a DockerinDocker solution, I got problem

    From console, looks  the "docker build" and "docker push"  has been executed. But actually does not feel like this.

    At least, could not see new image created or stored in registry.

    And when use it along with "Execute build" (which does docker build; docker push) , does not show anything at all. It only pull the image from  "Build inside of a container" and successfully exit. 

    Did I miss anything or this is not a valid user case : use this plugin to start a container and inside of the container to "docker build" an application image then "docker push" to store in registry and "docker run" this application container with some testcase.

    Thanks!