Containerize your project with Docker
Being software professionals, we consistently play around new technologies and that involves Installation of one or more dependent software. And when it comes to setting up the prerequisites, it's a real pain when we follow the traditional approach.
Traditional approach:
- Get all the Installation files from a remote server.
- Follow the steps mentioned in the documentation/ confluence/ blogs/ videos for Installation part.
- It's most likely that you will encounter one or more error/warning messages during the installation process.
- Debug the issue. Search on the internet and fix the issues come up during the installation phase.
Example :
Let's talk about Installation of a web server "Apache Tomcat",
- Download the required installation file supported by your OS.
- Follow the installation steps mentioned in the documentation.
- Start the webserver to check if it is up and running or not.
- While starting up you found errors in the command line saying "Specified JRE installation does not exist".
- Oops! Now you need to Download and Install the required JRE/JDK and follow the above steps for the same.
Well, it's a simple web server installation, just think about a complex working environment setup where multiple dependent pieces of software need to be configured properly. To be honest, I found it's time-consuming and irritating to set up the whole environment before diving into the development/testing phase.
Before setting up a suitable working environment you might end up getting through above issue multiple times. Are you looking for a better alternative that will simplify your workflow and the whole installation process? Then you must have asked any of the below questions to yourselves in past,
- Is there a better way of setting up all dependencies so that you can focus more on Business logic from the first day itself?
- Is there a better way that will ease the whole deployment process of your application to production?
- Want to deploy multiple instances of your application over a cluster?
Any guess? Yes, it's "Docker".
What is Docker in layman terminology?
Docker is a tool that simplifies the whole workflow by providing us with a working environment for a given set of dependencies, libraries. In simple terms, it is a tool that is designed to make it easier to create, deploy and run the application by containers. A running piece of a unit in docker world is a container. So what is a container?
A Container is a running unit that allows the developer to package up an application with all the required dependencies, libraries. So when we need to run/ deploy our application to a new environment, all we need to do is to create a running container out of a Docker image. So what is a Docker image now?
A Docker image is what we're planning to build that contains all the dependencies, libraries and the application that we're trying to containerize.
Steps:
- Download and install Docker.
- Create a Dockerfile(properties file in text format) contains all the information regarding dependencies, libraries and path to the source code of our application.
- Build an image out of the docker file and push to docker hub(Repository of docker images)
- Create a container out of the built image.
The above-mentioned steps to create an image is a one-time process. So every time we need to deploy and run the application in a new environment, we just need to follow the step:4 i.e to create a running container out of the image file.
In this article, I have explained the Docker in simple terms by hiding many technical details. In the next article, I'll cover the technical aspects and simple demo.
Software Engineer
4 年Good one Bro
Software Engineer 2 @ Microsoft | Ex-SDE @ Amazon | Master's in Computer Science @ ASU
4 年I wish I had read this article 3 months back, would have helped me ace an interview ?? Great post Harsit ! Very simple and straight forward approach. Loved it. If possible elaborate on kubernetes as well in your next post (if you plan on writing more such pieces)