Automating the build process for images

You learned how to build images locally and push these images to Docker Hub. Docker Hub also has the capability to automatically build the image from the Dockerfile kept in the repository of GitHub or Bitbucket. Automated builds are supported on both the private and public repositories of GitHub and Bitbucket. The Docker Hub Registry keeps all the automated build images. The Docker Hub Registry is open source and can be accessed from https://github.com/docker/docker-registry.

We will discuss the steps needed to implement the automated build process:

  1. We first connect Docker Hub to our GitHub account.
  2. Log in to Docker Hub from https://hub.docker.com/login/, click on Create, and then navigate to Create Automated Build, as shown in the following screenshot:
  1. We'll now select Link Accounts:
  1. Once GitHub is selected, we will select Public and Private (Recommended), as shown here:

After clicking on Select, your GitHub repository will now be shown.

  1. Now, provide the GitHub credentials to link your GitHub account with Docker Hub and select Sign in:
  1. After a successful login, the Linked Accounts & Services screen looks like the following screenshot:

So, whenever the Dockerfile is updated in GitHub, the automated build gets triggered and a new image will be stored in the Docker Hub Registry. We can always check the build history. We can change the Dockerfile on the local machine and push it to GitHub. Now, we can see the automated build link of Docker Hub at https://hub.docker.com/r/vinoddandy/dockerautomatedbuild/builds/:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset