Your application is passed all the tests and is ready to deploy. Now you planned to deploy the application using Docker. If you want to deploy an application as a container using Docker, then first you need to create Dockerfile for the application and build a Docker image using the Dockerfile. Then you can push the Docker image to the Docker hub or any image repository manager(AWS, GCP, and Azure). From the Docker hub repository, you can run a container for the application anywhere in the cloud.
How To Push a Docker Image To Docker Hub:
1. Create a Dockerfile for the application.
2. Build the application as an Image using Dockerfile.
3. Push the image to Docker Hub.
I already created an article for pushing the Docker image to the Docker hub. To learn more about it, please follow the link.
Dockerfile Explained | Dockerize NodeJS Application
Learn how to create Docker images for custom NodeJS applications.
You can do the above-mentioned steps manually. But the goal of this article is to automate the Docker image creating and pushing process by using Jenkins and Bitbucket. We will add two files to the existing application. They are Dockerfile and Jenkinsfile. Dockerfile is used to create a Docker image. Jenkinsfile is used to build the image using Dockerfile and push the image to the Docker hub.
Docker hub offers an unlimited public repository for Docker images. I used public repo for demonstration purposes. But in real-time we always use the private repo to store all the application images. Every beginner developer may have a question in their mind like do we need private or public repo for Docker images?. Of course, you need private repo…