Introduction to Docker
In this blog post, I’ll introduce you to the world of containerisation - Docker.
Introduction to Docker
What you’ll learn
Imagine this scenario, I wanted to deploy my application named ( testapp ) in the production environment. I hand over my code to the ops guy for the deployment. Wait, here is the catch. Now the ops guy comes back to you saying that your code doesn’t work in the production environment. And now the developer blames the ops guy.
This is because your dev environment ( where you wrote and tested your code) is different from the production environment. Dev environment is also different from the testing environment. There may be many reasons for the failure of the code. It may be due to 3rd party dependency, version error etc., Don’t you think we need a common environment in which every team can work trusting that their code with always run. Docker comes to the rescue. Docker creates that “common” environment ( docker images ) and each team can run their own instances ( docker containers ).
We may have to install many dependency tools. And remember, we can’t spend more time on installing those 3rd party tools and resolving all dependency or version error that may occur. We want to build, deploy and run in “hours”. ( Note the double quotes on hours ). Gone are the days, where you wait for 3 months for a release to happen.
Difference between Docker and Virtualisation
VM’s and containers work almost the same. The main difference being the absence of Hypervisors ( Like Hyper-V) in containers. The containers don’t need a guest OS, instead, they sit on the base OS. This is achieved by use of Docker Engines. To understand better, you can think of Docker Engines like the bytecodes in java. It is platform independent. You can always run a container if you have docker engine installed.
Spinning up a ubuntu instance
You can download docker from their official website - https://www.docker.com/
Once you have the set up ready, check if the docker is installed using the following command
As you can see, docker is installed. Now we need to download ubuntu image from the docker hub. Docker hub is where all your docker images are hosted. It is similar to GitHub. You can have public and private images as well.
docker search ubuntu
And pull any of the ubuntu installation using the following command
docker pull ubuntu ( image name )
Once you have installed your image. You can check the list of available images using the following command
As you can see, It list all my docker images and the date at which it is created. We are interested in spinning up a ubuntu machine. Use the following command
docker run -i -t ubuntu bash
As you can see, I’m inside the ubuntu machine. Now imagine this ubuntu machine to be your test app. Now you can deploy this app to your dev, test, and prod environment. Everything remains the same and the code will run without any error. You can reap the benefits of containerization feature in docker and apply to your security field - DevSecOps. Hope you understood the importance of docker. Please feel free to suggest any comments.
Refer to my blog for more updates on docker and application security.
Thanks and Regards,