page_title: Automated Builds on Docker Hub page_description: Docker Hub Automated Builds page_keywords: Docker, docker, registry, accounts, plans, Dockerfile, Docker Hub, docs, documentation, trusted, builds, trusted builds, automated builds
Automated Builds are a special feature of Docker Hub which allow you to
use Docker Hub's build clusters to automatically
create images from a specified Dockerfile
and a GitHub or Bitbucket repo
(or "context"). The system will clone your repository and build the image
described by the Dockerfile
using the repository as the context. The
resulting automated image will then be uploaded to the Docker Hub registry
and marked as an Automated Build.
Automated Builds have several advantages:
Users of your Automated Build can trust that the resulting image was built exactly as specified.
The Dockerfile
will be available to anyone with access to
your repository on the Docker Hub registry.
Because the process is automated, Automated Builds help to make sure that your repository is always up to date.
Automated Builds are supported for both public and private repositories on both GitHub and Bitbucket.
To use Automated Builds, you must have an account on Docker Hub and on GitHub and/or Bitbucket. In either case, the account needs to be properly validated and activated before you can link to it.
In order to set up an Automated Build, you need to first link your Docker Hub account with a GitHub account. This will allow the registry to see your repositories.
Note: Automated Builds currently require read and write access since Docker Hub needs to setup a GitHub service hook. We have no choice here, this is how GitHub manages permissions, sorry! We do guarantee nothing else will be touched in your account.
To get started, log into your Docker Hub account and click the "+ Add Repository" button at the upper right of the screen. Then select Automated Build.
Select the GitHub service.
Then follow the onscreen instructions to authorize and link your GitHub account to Docker Hub. Once it is linked, you'll be able to choose a repo from which to create the Automatic Build.
You can create an Automated Build from any of your
public or private GitHub repositories with a Dockerfile
.
If your repository contains links to private submodules, you'll need to add a deploy key so that the Docker Hub will be able to clone the repository from GitHub.
Your Docker Hub deploy key is located under the "Build Details" menu on the automated build's main page in the Hub. Add this key to your GitHub submodule by viewing the Settings page for the repository on GitHub and selecting "Deploy keys".
GitHub organizations will appear once your membership to that organization is made public on GitHub. To verify, you can look at the members tab for your organization on GitHub.
Follow the steps below to configure the GitHub service hooks for your Automated Build:
In order to setup an Automated Build, you need to first link your Docker Hub account with a Bitbucket account. This will allow the registry to see your repositories.
To get started, log into your Docker Hub account and click the "+ Add Repository" button at the upper right of the screen. Then select Automated Build.
Select the Bitbucket source.
Then follow the onscreen instructions to authorize and link your Bitbucket account to Docker Hub. Once it is linked, you'll be able to choose a repo from which to create the Automatic Build.
You can create an Automated Build from any of your
public or private Bitbucket repositories with a Dockerfile
.
When you link your Docker Hub account, a POST
hook should get automatically
added to your Bitbucket repo. Follow the steps below to confirm or modify the
Bitbucket hooks for your Automated Build:
During the build process, Docker will copy the contents of your Dockerfile
.
It will also add it to the Docker Hub for the Docker
community (for public repos) or approved team members/orgs (for private repos)
to see on the repository page.
If you have a README.md
file in your repository, it will be used as the
repository's full description.The build process will look for a
README.md
in the same directory as your Dockerfile
.
Warning: If you change the full description after a build, it will be rewritten the next time the Automated Build has been built. To make changes, modify the
README.md
from the Git repository.
If you need a way to trigger Automated Builds outside of GitHub or Bitbucket, you can set up a build trigger. When you turn on the build trigger for an Automated Build, it will give you a URL to which you can send POST requests. This will trigger the Automated Build, much as with a GitHub webhook.
Build triggers are available under the Settings menu of each Automated Build repo on the Docker Hub.
Note: You can only trigger one build at a time and no more than one every five minutes. If you already have a build pending, or if you recently submitted a build request, those requests will be ignored. To verify everything is working correctly, check the logs of last ten triggers on the settings page .
Automated Builds also include a Webhooks feature. Webhooks can be called after a successful repository push is made.
The webhook call will generate a HTTP POST with the following JSON payload:
{
"push_data":{
"pushed_at":1385141110,
"images":[
"imagehash1",
"imagehash2",
"imagehash3"
],
"pusher":"username"
},
"repository":{
"status":"Active",
"description":"my docker repo that does cool things",
"is_automated":false,
"full_description":"This is my full description",
"repo_url":"https://registry.hub.docker.com/u/username/reponame/",
"owner":"username",
"is_official":false,
"is_private":false,
"name":"reponame",
"namespace":"username",
"star_count":1,
"comment_count":1,
"date_created":1370174400,
"dockerfile":"my full dockerfile is listed here",
"repo_name":"username/reponame"
}
}
Webhooks are available under the Settings menu of each Automated Build's repo.
Note: If you want to test your webhook out we recommend using a tool like requestb.in.
Repository links are a way to associate one Automated Build with another. If one gets updated,the linking system triggers a rebuild for the other Automated Build. This makes it easy to keep all your Automated Builds up to date.
To add a link, go to the repo for the Automated Build you want to link to and click on Repository Links under the Settings menu at right. Then, enter the name of the repository that you want have linked.
Warning: You can add more than one repository link, however, you should do so very carefully. Creating a two way relationship between Automated Builds will cause an endless build loop.