Docker container was my diploma final year project. I like to share the details of project in blog.
Linux containers and Docker are used to change the way of building shipping, deployment and instantiation of applications. Docker accelerate application delivery along with their dependencies. Therefore, the same containerized application can operate in different development, production, test and operating environments. The platform can be a public cloud, physical or virtual server or network device. Virtual machine requires hypervisor to handle multiple operating systems. Therefore, we can use docker for this purpose. Docker can be used for the purpose of virtualization. In this paper, we can containerize our application using docker and pull the images.
Virtualization is referred as an act of creating virtual version of something including virtual computer, hardware platform, storage device operating system, or computer network resources. It allows multiple operating system to run simultaneously on a single computer. It means single hardware of a single system can be used for multiple operating system. Each guest OS is managed by a Virtual Machine Monitor (VMM). VMM is also known as a hypervisor. Virtualized system sits between the guest and the hardware. It can control use of CPU, memory and storage of guest operating system. It also allows a guest OS to migrate from one machine to another.
Virtualization can be used as modified solution between centralized and decentralized deployments. In virtualization, each application can be given its own operating system and all those operating systems can reside on a single piece of hardware instead of purchasing and maintaining an entire computer for one application. The concept of docker is mainly based on virtualization.
2. Cloud Computing:
Cloud computing is nothing but using a network of remote services hosted on the internet to manage, store and process data rather than a local server Clouds are just like virtual machines. Clouds provide flexible access to the computing resources remotely across the internet or intranet. Cloud computing is a type of internet based computing where different services-such as storage, servers and application are delivered to an computers and devices through the internet.
Cloud computing involves deploying services to cloud clients including groups of remote servers and software networks that allow centralized data storage and online access to computer resources.
• Service Models of cloud computing:
Cloud computing provides their services through following fundamental models:
1 .Platform as a service (Paas):
In the PaaS models, cloud providers deliver a computing platform to cloud users which includes operating system, programming language execution environment, web server, and database.
2. Infrastructure as a service (Iaas):
Iaas provides the computing resources to users. It includes physical or virtual machine and often offer additional resources such as a virtual-machine disk image library, file or object storage, firewalls and software bundles.
3. Software as a service (Saas):
In the SaaS model, cloud providers install and operate application software in the cloud and cloud users access the software from cloud clients. This eliminates the need to install and run the application on user’s own computers, It also simplifies maintenance and support. Cloud users do not manage the cloud infrastructure and platform where the application will run.
• Docker Container :
Docker is an open platform for developers and system administrators. It can be to build, ship and run distributed applications. It consist of Docker Engine and Docker Hub. Docker Engine is a portable, lightweight runtime and packaging tool and Docker tool is a cloud service for sharing applications and automating workflows. Docker enables applications to assemble quickly from components. This eliminates the friction between development and production environments. As a result, IT can ship fast and run the same app on laptops, data center, VMs, and any cloud.
Docker automates the deployment of applications inside software containers. Docker uses Linux kernel feature called resource isolation features. In this feature groups and kernel namespaces allows independent containers to run within a single Linux system. It avoids the overhead of starting virtual machines. Containers allow a developer to package up an application with all it’s parts such as libraries and other dependencies. By doing so, the developer can rest assured that the application will run on any other linux machine regardless of any other machine that could be differed from the machine on which application is developed.
• Every virtualized application along with necessary libraries and binariesbut also the entire guest operating system. It also it require hypervisor for handling multiple virtual machines on host system.
The docker engine container comprises just the application and its dependencies. It run as an isolated process in user space on the host operating system which include sharing the kernel with other containers. Thus, it enjoys the allocation benefits of VMs and resource isolation. Docker is much more portable and efficient then virtual machine.
1. For the purpose of virtualization, we uses virtual machine technology. This technology actually reduces concentration risk when deploy in the right configurations.
2. You can always achieve more failures using fewer x physical machines and hosting more than x virtual machines that are networked to watch each other and also causes the failure of partner machine.
3. Another problem of virtual machine is licensing cost.
4. Virtual machine technology requires hypervisor to manage operating system and guest operating system.
So docker can be used in place of virtual machine to avoid problems. To work with docker, we have to create, pull or push the images. In this project, we have installed Docker software on Windows machine. Images can be created by using two ways:
1. Via docker commit command.
2.Via docker build command of Dockerfile.
We will use second method for docker.
For starting docker software on the Windows machine, we have to use Command prompt.
Redirect command prompt to docker installed folder and type following commands:
i.boot2docker init ii.boot2docker start iii.boot2docker shellinit
iv. boot2docker ssh(this command is used to enter linux shell)
Pulling images from docker hub:
• Inside Docker Hub, images are stored in repositories. It contains images, layers, and metadata about those images.
• A big part of image building is sharing and distributing your images. We do this by pushing and pulling them to the Docker Hub or your own registry. To facilitate this, first we have to create account on Docker Hub.
• The command “sudo docker images” gives the list of docker images.
• “hello-world” image is pulled by using “docker run hello-world”.
List of images in docker:
The command “sudo docker images” gives the list of images present in docker.
Downloading the tomcat Container of Docker:
Apache Tomcat is an open source web server developed by Apache Software Foundation (ASF).It is a servlet container which implements the Java Servlet and the Java Server Pages (JSP) specifications from Oracle. Tomcat is one of the container of Docker that we downloaded. To download the tomcat container use following command: docker run tomcat.
The command “boot2docker shellinit” provides the information about docker Ip address and other. We used that IP address to run tomcat container. To run the tomcat container, we use following command: docker run –it –-rm tomcat:8.0” (8.0 is version).While running the tomcat, if port problem occurs then we have to assign the port to tomcat(port forwarding) by using following command: docker run –it –rm –p 8888:8080 tomcat:8.0.If tomcat run successfully, then we check it on browser by using IP address and port number 192.168.59.103:8080.Here IP address used given by shellinit. Homepage of tomcat is displayed on browser.
Running of servlet program using Tomcat:
We have created one servlet program that we run through tomcat. For that we have to create war file of that file (For that we can use extractor or Netbean).Then run tomcat container on browser.In docker commamd prompt redirect address to tomcat container and create one folder in that. Then copy that war file in “C:\Users”.Assign default permissions to war file using docker command prompt using touch command: touch filenm. Create docker file in our own directory using command:
cat> Dockerfile FROM tomcat MAINTAINER xyz
SessionWebApps is our file name. Build our own image of war file using command: docker build
–t myimage .myimage is a name given to SessionWebApps.war file in docker. After that we run war file on docker command prompt: docker run –it –rm –p 8888:8080 myimage. Then we will check it on browser using:192.168.59.103:8080/SessionWebApps.
After running SessionWebApps on browser using tomcat container, we will get following output.
In this output, it asks for user name and password to login. If we provide correct information then it allows us to login.
Docker container can be used as one background daemon. Docker containers isolation is not like a virtual machine because docker is fast and versatile. Docker is perfect for short lived apps that is no longer data persistence. In this paper, we created our own image and run successfully. Also we pulled the image of docker. Hence, we conclude that docker will be useful for the system administration and application developers to create, build and run apps in different environments.