Docker Hub Automated Build
In my post Docker Hub Hello World, we learned how to walk with Docker Hub. Creating a manual docker build and uploading it was a great first step. But, it's nothing to brag about yet.
In this post, we will be going through the Docker Hub Automated Build tutorial.
Automated Builds have several advantages:
- Images built in this way are built exactly as specified.
- The
Dockerfile
is available to anyone with access to your Docker Hub repository.- Your repository is kept up-to-date with code changes automatically.
So let's do this!
Prerequisites
If you have followed previous posts, you are already mostly the way there! The prerequisites are having a Docker Hub and a GitHub (or BitBucket) account.
Follow the steps to 'Link to a hosted repository service'.
Create an Automated Build
If we didn't hit roadblocks, then why the hell would I blog about anything?
The Docker Hub tutorial assumes you have a repository to build from. So, what should a Docker Hub automated build repository look like? All I can say is, thanks Google! (It's my superpower, Let me Google that for you)
How to Automate Docker Builds and Auto Deploy
At this point, I switched from the Docker Hub tutorial to How to Automate Docker Builds and Auto Deploy. I am halfway through this tutorial and am trying to understand what is going on instead of blindly following along.
- Create a Repository
git clone https://github.com/DEV3L/docker-hello-world
- Add Docker as a service through the repository settings
- Settings > Webhooks & Services > Docker
- Create an Automated Docker Build linking to the GitHub repository clone
- Make a code change
- An automated build is triggered!
- Pull your Docker image
docker pull dev3l/docker-hello-world
- Run the Docker image
docker run -d -p 80 dev3l/docker-hello-world
- View the application in the Web Browser
docker port d35bf1374e88 80
- The id should be the ID of your container
docker ps
- It will print the port
Conclusion
This is just another small step in our Docker journey.
In tutorials so far, we have covered how to setup Docker, how to deploy Docker to Amazon Web Services, how to host your own Docker files, and in this article, how to create automated builds to produce Docker files.
The problem is, this is still following other people's prototypes and hello-world examples. I have been recently working through a React.js Fundamentals course. In future blogs, I want to walk through steps of deploying these React.js applications.
Get In Touch
We'd love to hear from you! Whether you have a question about our services, need a consultation, or just want to connect, our team is here to help. Reach out to us through the form, or contact us directly via social media.