In this post, we will be discussing how industries are using docker with the help of a case study of Indiana University.also, we will be discussing on installation & configuration of the docker.
What you will learn:
- Why we need docker?
- What is docker?
- Installation of Docker on Ubuntu
- Realtime Example
- Components of docker
- Realtime Case study on Docker
Why we need Docker?
As you can see in the below image that is the most common problem were industries are facing right now.
As you can see there is a set of a developer that builds the application which running fine in the testing environment.but when it reaches the production server there are some certain issues with that application.
Why does it happen?
It happens because of different computing environments between test & production
Before moving to problem 2 it is important to understand the micro-services.
What is micro-services?
Consider an application and that application is broken down into small services each of those services can be termed as micro-services or else we can put it in another way also
Micro-services can be considered as small processes that communicate with each other over a network to fulfill one particular goal.
So let’s discuss what is micro-services with the example.
You can see in the below picture, there is an online shopping service application it can be broken down into smaller micro-services like account service, product catalog, cart server, order server.
Micro-service architecture is gaining a lot of popularity in now days even giants like Facebook, amazon are adopting a micro-service architecture
There are three major reasons for adopting micro-services architecture or you can say the advantages of micro-service architecture.
- There is a certain application that is easier to build and maintain when they are broken down into smaller pieces or smaller services.
- Suppose I want to update a particular software or I want a new technology stack in one of my modules or one of my services we easily do that because dependency concerns will be very less.
- If any of the modules or services get down then the whole application remains largely unaffected.
Problem Before Docker
There is one way to implement micro-services architecture before the docker you can see in the below picture.
As you can see there is one host machine and top of that host machine there are multiple virtual machines available.
Each of those machines contains the dependencies for one microservice.so major disadvantage here is in the virtual machine there is a lot of wastage of resources such as RAM, processor, disk space is not completely utilized by the microservices which is running in these virtual machines.
So this is not the ideal way to implement micro-services.
How docker solves all these problems.
So let’s take one example shown in the below picture.
Here we have one host machine and top of that we have one virtual machine which contains the multiple numbers of Docker containers.
So let have a quick look at what is a docker container?
Docker container is a lightweight alternative for the virtual machine that means in docker container you don’t need to preallocate the RAM or any disk space so it will take the disk space and ram according to the application requirement.
You will get the question in your mind by seeing the above picture that why we are using a virtual machine here?
Let me tell you first the host machine should be Linux based machine in order to run a docker container because docker containers do not work on windows based host machine.
So if you have a windows system you will require Linux system then you can run the docker containers.because of this reason only we have used a virtual machine here.
What is docker?
Docker is a tool designed to make it easier to create, deploy, and run the application by using containers.
Containers are lightweight alternatives to the virtual machine and it used the host machine. you don’t have to preallocate ram and disk space to the container.
Let’s look at the below picture
Docker containers do not use the guest operating system, it uses the guest operating system.
Let us refer to the diagram as you can see at the bottom there is a host operating system and top of that there is a docker engine and with the help of this docker-engine docker containers are formed.
These containers have the application running in them and the requirement for those applications such as all the binaries and libraries are also packaged in the same container.
Docker Installation On Linux based system Ubuntu
Now, let us see the steps to install docker.
Step 1: To ensure the download are valid, add the GPG key for the official docker repository into your system by the below command.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 2: Add the docker repositories to the apt resources by the below command.
sudo add-apt-repository "deb [arch=amd64]https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 3: Update package database with the docker package which is added through the repository using the below command.
sudo apt-get update -y
Step 4: Make sure you are installing docker from docker repositories and not from Ubuntu repositories by using the below command.
apt-cache policy docker-ce
Step 5: Install the docker community edition using the below command.
sudo apt-get install -y docker-ce
Run Docker commands without sudo
Step 6: Add the docker group if it doesn’t already exist
sudo groupadd docker
Step 7: Add the connected user $USER to the docker group
Note: Optionally change the username to match your preferred user.
sudo usermod -aG docker $USER
Step 8: Restart the docker daemon
sudo service docker restart
We have successfully completed the installation of docker in Ubuntu.
Docker In A Nutshell
One way of using docker or you can say the workflow of the docker shown in the below picture.
Over here what is happening is a developer writes a code that defines application requirements the dependencies to the docker file and this docker file produces docker images.
So whatever dependencies required for an application is present in the docker image.
The run time instance of docker images called a docker container
Docker hub is nothing but a git repository for docker images.it contains public as well as private repositories so from public repositories you can pull your image and also you can upload your own images to the docker hub.
From the Docker hub, various teams like QA or production team will pull the image and prepare their own container as you can see from the picture.
Advantage of this workflow
- Docker file builds a docker image and that image contains all the projects code.
- You can run that image to create as many docker containers as you want.
- This image can be uploaded on docker hub, from docker hub anyone can pull the image and build the container.
- Create complex requirements for a microservices within an easy-to-write Dockerfile.
- Push the code into the GitHub repository
- CI server pulls it down and builds the exact environment that will be used in production to run the test suits without needing to configure the CI server at all.
- Deploy it out to a staging environment for the tester.
- Roll exactly what you had in development, testing, and staging into production.
If you can recall the first problem we have discussed earlier that application is working fine in the development environment but not in a production environment so with this workflow we can completely remove that problem using this workflow.
Docker Case Study Indiana University
Problem Statement 1 & 2
Indiana University was using custom scripts to deploy their application on various VM so this required lots of manual steps
Their environment was optimized for their legacy java-based applications.
Problem Statement 3
The university wanted to improve the way they architect applications, by moving to microservices-based architecture for their applications.
Problem Statement 4
Security was needed for students’ data such as SSNs and student health data.
Now let us see how they have implemented docker to solve the above issues.
Solution for all these problems is Docker Data Center (DDC)
Docker Trusted Registry
It is nothing but the storage of all your docker images and each of those images contains dependencies for one micro-service.
As we saw in the above problem statement that Indiana university wanted to move from monolithic architecture to microservice architecture.
UCP Web UI
It is used to deploy the services on various hosts with the help of docker images that are stored in the docker trusted registry.
So, the IT and Ops team can manage the entire infrastructure from one single place with the help of a universal control plane web user interface.
When we talk about data security the role-based access controls within the docker data center allowed Indiana university to define the level of access to various teams.
For example, they can give read-only access to docker containers for the production team.at the same time, they can actually provide read and write access to the development team.
The Docker registry is nothing but the storage of all your docker images.we can store the images in either public/private repositories.
These repositories can present locally or it can be on the cloud. Docker provides a cloud-hosted service called the docker hub.
Why use the docker registry?
- Control where your images are being stored.
- Integrate image storage with your in-house development workflow.
Docker images are nothing but the read-only templates that are used to create containers. these docker images contain all the dependencies for a particular application for a micro-service.
You can create your own image upload that on to the docker hub and at the same time you can pull the images which are available in the public repository.
Docker containers are nothing but the run time instances of docker images.it contains everything which is required to run an application or micro-services.
Working with Docker Images
Docker containers are run from Docker images. Most of the images you will get it from the docker hub.image which is nothing but an environment like Linux, Unix, Ubuntu.
Anybody can build and host their Docker images on Docker Hub, so most applications and Linux distributions you’ll need to run Docker containers have images that are hosted on Docker Hub.
Step 1: To check whether you have access and can download the image from the docker hub use the below command.
sudo docker run hello-world
Step 2: Search for the Ubuntu image by using the below command.
sudo docker search ubuntu
The OFFICIAL column, OK indicates an image built and supported by the company behind the project.
Step 3: Pull the image from the docker hub by the below command.
sudo docker pull ubuntu
Docker Operations On Containers
Step 4: create the container using the below command.
sudo docker run -it ubuntu
Step 5: Start the container using the below command.
sudo docker start <container ID><br>
Step 6: Stop the container using the below command.
sudo docker start container ID
As you can see we have successfully installed docker in our system and performed some basic tasks and executed the commands on docker.
we have discussed how industries are using docker with the help of a case study of Indiana University.also, we have discussed how to install & configure the docker.