Skip to main content

Docker Automated Builds

When it comes to "dockerization" of your application, it might be possible that your apps are under continuous development and needs to generate new docker image frequently based on the app updation.
So, if haven't gone through my previous Articles regarding Docker Overview and Docker Basics, then please go through those first.

Solution: Automation of the Docker Build using Docker Automated Build feature of hub.docker.com

How? Let's find out.

All we have to do is to link Docker and Github to automate the build process. Following steps will teach you to do so with a sample project on Github.

Step 1: Create account on both Github.com and hub.docker.com

Step 2: Create a repository on the Github as per your requirements.

Step 3: Create a file named as "Dockerfile" with the following contents


FROM ubuntu:16.04

USER root
WORKDIR /root

RUN apt-get update -y \
    && apt-get install -y apache2

RUN service apache2 restart

EXPOSE 80:8080


Step 4: Commit and merge with the master.

Step 5: Go the hub.docker.com

Open Create > Create Automated build
Click Automated Build with Github

Step 6: Follow the steps to grant full access of Github account to the hub.docker.com

Step 7: Select your Github repository ,fill out the description and click Create.

Step 8: Commit some changes in your Github repository to trigger the Build. (Like changes in README.md file)

Step 9: Come back to hub.docker.com, open your Automated build repository and open the build section. You will find one build running. It will take couple of minutes to finish.

In the end your Docker image will be ready with the latest tag.

Comments

Post a Comment