Create the Docker image from the Dockerfile present on Github

Reading Time: 3 minutes

In this we will write a dockerfile which is present on the github and with that we are creating the docker image . Docker image is build on your dockerhub repository . We can say that we are setting up automated builds .


Github is a specific open-source version control system created by linus torvalds in 2005 . It is distributed version control system which means that the entire code-base history is available on every developer’s computer . This allows easy branching and merging . For more you may also follow official doc .


It is software platform for building application based on containers . Docker container can run anywhere on-premises or cloud . Containers in the docker is lightweight with greater resource efficiency . This improves the productivity of developer as containers in docker are faster than the virtual machine . For more you may follow the official documentation .


  • Knowledge of both git and docker
  • Account on github and dockerhub
  • Dockerhub account should be pro,team or business subscription .

Write a code on github

At the first step we will be creating a repository with any name . Then write the code or we can say that write a docker file and push it on the github.

In that repo we also need to add the the index.html file and in that write any message which we want to print as the webpage of nginx . With this , our github work is done . Now go ahead with the dockerhub .

Create repository on dockerhub

First we have to create a repository on dockerhub . After this we have to open that repo and click on build section , as shown in picture .

For this your account must have pro , team or business subscription . When you click on build section than 2 options will appear one is link to github and link to bitbucket . Choose any option where your dockerfile is present . After you linked up with your git repo , follow the step below mention in the image

I have done the auto-test off . If we on this test then it will automatically make changes in the image when ever you push some thing in github repo . Click on save and build . It will take some time for building up the image . When your build is successful then you will see the build activity as in success ( given below )

Now we will pull the docker image on your server by using docker commands

docker pull [OPTIONS] NAME[:TAG|@DIGEST]

You will see that your image is pulled and then start the container with that image .

docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]

Now find out the ip address of that container through the command

 docker container inspect [OPTIONS] CONTAINER [CONTAINER...]

In the last just do curl with that ip addresss and we will get the output that we have defined in that index.html file on github repo . We can also say that this set up automated build in docker .

References :-

  • For automation build you may also follow official doc .
  • I have this dockerfile on my github .

Leave a Reply