The more time I spend with Docker the more ideas and problems I can solve with Docker. Using Docker in combination with other services expands the possabilites even further such as Tutum.

This article describes how to create an Automated Docker Build that auto deploys Docker containers in combination with these services GitHub -> Docker Hub -> Tutum. I've come across several articles that describe one portion of this process but I've yet found something that covers the entire end-to-end Docker deployment. So why not type it out.

Create a Hello World Fork

Let's start by forking my GitHub Repo from Docker-Hello-World oringally from TutumCloud. I cleaned up the Repo a little so it is easier to navigate and edit. Once you Forked the repo click on the Settings icon on the right side of your newly created Repo.



On the left side of the settings screen click Webhooks & Services. Click add service and find the Docker service.



Create an Automated Build Docker Repository

If you don't have a Docker Hub Account you should sign up for one now. Once logged into the Docker Hub, click the Button below your username +Add Repository --> Automated Build

Select GitHub as the source.



Finally, select the new Repository you forked in GitHub. My example below shows my Docker-Hello-World Repo.



Keep the default values on the next page and click Create Repository . Your GitHub Repo is now linked to your Docker Hub. Any changes that you perform inside your Forked Repo in GitHub will automatically generate a new build inside of Docker Hub.

Open your newly created Docker Repository and click on the Build Details tab. Here you will see your build history. If you want to give a build a try click the blue button on the right side start build This will build a new docker image based on your fork inside of your GitHub account. Neat, huh?

Auto Deploy new Containers with Tutum

Now that we have GitHub and Docker linked let's take it one step further. We will now link Docker with Tutum. Tutum is an amazing PaaS (Platform as a Service) tool for Docker Containers which allows you to build, deploy, and manage Docker Containers across your cloud. Tutum is the provisioning portal for your Docker infrastructure. Your data and your servers are still managed by you.

Sign-in to Tutum with your Docker account as we want to link directly to Docker. Once you've signed-in I advise you to follow the getting started guide by Tutum which walks you through setting up a Docker server with Tutum. Connecting to your own server infrastrucuture or 3rd Party Clouds like Amazone or Digital Ocean is possible. Whatever you choose it's incredibly simple.

Once you built your first node (Virtaual Machine that is connected to Tutum) we can now deploy our the service we created with our Github Repo. Login to the Tutum Dashboard and click the Services Tab .

Inside the Services Tab click the Create Service button.

We will now search the Dockerhub for our Repo. In my example below I typed my username in the searchbox vegasbrianc which returns my repos available inside of the Dockerhub. Click the Select button on the Repo name you created. Docker-Hello-World is my example below.



Name your container

Click on the greyed out Ports section

Click Publish Port and change the port from Dynamic to port 80.

Click the Create & Deploy button



After your service is up and running open your service and open the Endpoints tab. Here you will see the Service Endpoints and a hyperlink. Open this hyperlink. You should see your docker-hello-world container up and running. Yeah it's that easy!

Once you've verified that your container works click on the Webhooks Tab. Follow the Tutum guide on how to setup Webhooks for your service. This will link Tutum to the Docker Hub allowing Tutum to monitor Docker Hub for updates. If Tutum sees a new build it will then redeploy your service with the new verison.

Conclusion

We've now built an Automated Docker build configuration that auto deploys containers once a new version is found. Amazingly simple isn't it? Can you think of the possabilites now with such a setup?

Make some changes in your Github repo. Change the Hello World text and save the index.php. This will kick-off a new build inside of the Docker Hub which then notifies Tutum to redeploy a new version which is all seamless. However we do have downtime between versions which we will cover how to fix in future articles.

This setup will be the foundation for future articles where I'll dive deeper into Continous Integration (CI), Continuous Deployment (CD) and A/B Testing with Docker and Tutum.