﻿<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><body><sec id="s1"><title>1. Docker Technology Introduction</title><p>Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux. Docker implements a high-level API to provide lightweight containers that run processes in isolation, and could provide virtualization solutions [<xref ref-type="bibr" rid="scirp.93423-ref1">1</xref>] . Currently, PAAS and IAAS architecture patterns are gradually changed in cloud computing platform, instead, major cloud service providers have successively provided docker-based container cloud services [<xref ref-type="bibr" rid="scirp.93423-ref2">2</xref>] .</p><sec id="s1_1"><title>1.1. Docker Container and Virtual Machine</title><p>Both Docker container and virtual machine are used for resource and environment isolation [<xref ref-type="bibr" rid="scirp.93423-ref3">3</xref>] . Virtual machine draws upon the Hypervisor to virtualize hardware resources, such as CPU, memory, I/O devices, etc. [<xref ref-type="bibr" rid="scirp.93423-ref4">4</xref>] . Its essence is to simulate plenty of virtual servers on a physical server, and these virtual servers can operate like a real server for a variety of application deployment. However, the price that comes with the convenience is that each virtual machine needs more hardware resources. Docker based on the host operating system kernel adopts Cgroup and Namespace to implement resource isolation, which does not need a complete operating system instance. Consequently, using Docker can greatly reduce the resource occupancy of server CPU, memory and so on [<xref ref-type="bibr" rid="scirp.93423-ref5">5</xref>] . The application that runs in the Docker container directly uses the hardware resource of physical machines, so that the Docker has certain advantages over the traditional virtual machine in terms of hardware utilization.</p></sec><sec id="s1_2"><title>1.2. Docker Framework</title><p>Docker follows a Client-Server architecture and is divided into three main parts. <xref ref-type="fig" rid="fig1">Figure 1</xref> shows the framework diagram of Docker. Docker_Host contains containers, images, and Docker daemons. It provides a comprehensive environment to run applications. Docker Client is the platform where the Docker Client interacts with the Docker daemon. The Docker Client sends a request command to the server, and the server performs the corresponding operations, such as building the image, running and distributing the container, and returning the result to the client. Docker hub/registry is responsible for sharing and managing Docker images. Users can upload or download the containing images. The official address is https://registry.hub.docker.com/, or you can set up your own private Docker registry. When pulling a mirror, if no warehouse address is specified, the default will stem from the public library maintained by Docker [<xref ref-type="bibr" rid="scirp.93423-ref6">6</xref>] . For better understanding Docker, some concepts are briefly introduced as follows. Docker image is a multi-level read-only application template with a complete runtime environment such as Linux, MySQL etc. These images are highly reusable. A</p><p>Mirror is used to create a container and one image can run multiple containers. Docker images can be customized, and the corresponding content is recorded by the Dockerfile. The advantage is that the operation and maintenance personnel only need the Dockerfile to create the specified container, which will greatly facilitate the propagation and storage of Docker images, achieving the follow-up [<xref ref-type="bibr" rid="scirp.93423-ref7">7</xref>] . A Docker container is a running instance of a mirror that can be switched on, started, stopped, or deleted. The container provides an isolated environment so that there is no interface between any containers. It is featured with the secure access to resources, which ensures that the programs in the container run in a relatively secure environment. Containers consume low resources and can be easily run on machines and data centers. Swarm is currently the only Docker officially specified cluster management tool. Starting from Docker 1.12, the swarm mode is inserted. It converts a system of multiple Docker hosts into a single virtual Docker host, allowing containers to form a subnet network across hosts.</p></sec></sec><sec id="s2"><title>2. Lab Information</title><p>All students in the Department of Information Engineering in our school are required to take the “Network Operating System” course in the third semester. Based on two ThinkServer QT940 servers, we have achieved virtualized cluster of servers and built 46 virtual machines, among which 22 are installed with Windows server2008 R2 while 26 are installed with CentOS7 using XenServer. 20 Windows-based virtual machines and 20 Linux-based virtual machines are provided for students with their Network Operating System course experiments. The remaining 6 are designated to software development and testing. As the demand gradually changes recently, at least 80 Windows virtual machines and 80 Linux virtual machines are simultaneously needed to support the teaching, and the existing virtual machine cluster resources cannot meet the demand. When students are studying web design, website development and other courses, they need to deploy databases, web services and other applications; also, the research teams of our department have put forward the need to build a more robust integration environment.</p></sec><sec id="s3"><title>3. Countermeasures</title><p>As we have mentioned above, Docker is featured with lightweight, fast startup, and low resource consumption. Therefore, we use the original virtualized cluster to build 82 virtual machines based on Windows. And we select two ThinkServer RD 630 to build an experimental environment for the Linux platform based on Docker. Details are shown in <xref ref-type="table" rid="table1">Table 1</xref>.</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Linux experimental environment establishment</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Server model</th><th align="center" valign="middle" >Host OS</th><th align="center" valign="middle" >Host Name</th><th align="center" valign="middle" >Host IP</th><th align="center" valign="middle" >Private Repositories</th><th align="center" valign="middle" >Cluster Node Role</th></tr></thead><tr><td align="center" valign="middle"  rowspan="2"  >Thinkserver RD 630</td><td align="center" valign="middle"  rowspan="2"  >CentOS7</td><td align="center" valign="middle" >Swarm01</td><td align="center" valign="middle" >192.168.3.2</td><td align="center" valign="middle" >Swarm01</td><td align="center" valign="middle" >Leader</td></tr><tr><td align="center" valign="middle" >Swarm02</td><td align="center" valign="middle" >192.168.3.3</td><td align="center" valign="middle" ></td><td align="center" valign="middle" >Worker</td></tr></tbody></table></table-wrap></sec><sec id="s4"><title>4. Procedure [<xref ref-type="bibr" rid="scirp.93423-ref8">8</xref>]</title><p>1) Install CentOS7, Docker on two servers respectively, and set the host name, IP address, and so on. OS and Docker versions are as follows:</p><p>CentOS7 version: 3.10.0-957.10.1.el7.x86_64</p><p>Docker version:</p><p>[root@swarm01 ~] # docker version</p><p>Client:</p><p>Version: 1.13.1</p><p>API version: 1.26</p><p>Package version: docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64</p><p>Go version: go1.10.3</p><p>Git commit: b2f74b2/1.13.1</p><p>Built: Tue Mar 12 10:27:24 2019</p><p>OS/Arch: Linux/amd64</p><p>Server:</p><p>Version: 1.13.1</p><p>API version: 1.26 (minimum version 1.12)</p><p>Package version: docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64</p><p>Go version: go1.10.3</p><p>Git commit: b2f74b2/1.13.1</p><p>Built: Tue Mar 12 10:27:24 2019</p><p>OS/Arch: linux/amd64</p><p>Experimental: false</p><p>2) To build a local mirror repository on Swarm01. First, pull registry and run. Then add a private image repository source by adding the following to the /etc/docker/daemon.json file on the server Swarm01 followed by a restart of Docker:</p><p>{</p><p>&quot;insecure-registries&quot;: [&quot;192.168.3.2:5000&quot;]</p><p>}</p><p>(3) Create a CentOS7 image that supports the SSH service on Swarm01 and push it to the local repository. Then, start the base image, create a new container named centos7ssh, and start a Bash terminal to interact with it. The centos7ssh image is shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>.</p><p>[root@swarm01 /] # docker run -it --name centos7ssh centos:7 /bin/bash</p><p>Container ID is: 276490788fca.</p><p>Add the SSH service to the container centos7ssh, then submit the container and convert it to a new image named sshd_centos7.</p><p>[root@swarm01 /] # docker commit 276490788fca sshd_centos7</p><p>sha256:1a89847f75ee631a89da101993e46ba743ab375ef8b175a874e0c4150e10156c</p><p>Tag it and push it to the local repository.</p><p>#docker tag 192.168.3.2:5000/sshd_centos7</p><p>#dockerpush 192.168.3.2:5000/sshd_centos7.</p><p>The result is shown in <xref ref-type="fig" rid="fig3">Figure 3</xref>.</p><p><xref ref-type="fig" rid="fig4">Figure 4</xref> shows the procedure of how to pull 192.168.3.2:5000/sshd_centos7 from the local repository in host Swarm02.</p><p>The following steps verify remote login to the container af674da76d8d. First, start the container that mirrors sshd_centos7 on the host Swarm01, and map the local port 15,000 to the port 22 of the container to start the SSHD service of the container.</p><p>docker run -d -p 15000:22 sshd_centos7 /usr/sbin/sshd ?D</p><p>[root@swarm01 /] # docker run -d -p 15000:22 sshd_centos7 /usr/sbin/sshd -D</p><p>af674da76d8d1d68152b5de34e88655bd20928128ac2c87839e83883a2eb0858</p><p>The result is shown in <xref ref-type="fig" rid="fig5">Figure 5</xref>.</p><p>Then, open a new terminal and enter the host IP address 192.168.3.2, port: 15000.</p><p>The result is shown in <xref ref-type="fig" rid="fig6">Figure 6</xref>.</p><p>4) Use the swarm mode to build a cluster to manage various types of containers. The management node is Swarm01 and the worker node is Swarm02. We should open the relevant firewall port of the host Swarm01#:</p><p>firewall-cmd --zone=public --add-port=2377/tcp --permanent</p><p># firewall-cmd --zone=public --add-port=7946/tcp --permanent</p><p># firewall-cmd --zone=public --add-port=7946/udp --permanent</p><p># firewall-cmd --zone=public --add-port=4789/udp --permanent</p><p>Initialize the cluster. The IP address of the nodes communicating with each other is 192.168.3.2, and the default port is 2377.</p><p>The result is shown in <xref ref-type="fig" rid="fig7">Figure 7</xref>.</p><p>Then, add the host Swarm02 to the cluster. The list of nodes is shown in <xref ref-type="fig" rid="fig8">Figure 8</xref>.</p><p>Up to now, the laboratory environment has been built and tested.</p><p>Teachers in each teaching could build a mirror image of students’ practice environment and create services according to the content of the course. Each teaching and research section could build a continuous integration environment according to their own needs, and optimizes program development, testing, system operation and maintenance.</p></sec><sec id="s5"><title>5. Concluding Remarks</title><p>In summary, Docker can quickly build and deploy applications, as well as build a highly flexible distributed system, making full use of hardware resources to reduce corresponding costs. After two months of operation, this experimental program solved the problem of insufficient server resources, and met the teaching needs of relevant courses and the research needs of the teaching and research section. Further research topic could be studying Docker’s security, resource isolation, and exploring its deep application in the actual development environment.</p></sec><sec id="s6"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s7"><title>Cite this paper</title><p>Hu, F. and Che, S.J. (2019) Establishment of the Docker-Based Laboratory Environment. Open Access Library Journal, 6: e5519. https://doi.org/10.4236/oalib.1105519</p></sec></body><back><ref-list><title>References</title><ref id="scirp.93423-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Bernstein, D. (2014) Containers and Cloud: From Lxc to Docker to Kubernetes. IEEE Cloud Computing, 1, 81-84. https://doi.org/10.1109/MCC.2014.51</mixed-citation></ref><ref id="scirp.93423-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Boettiger, C. (2015) An Introduction to Docker for Reproducible Research. ACM SIGOPS Operating Systems Review, 49, 71-79. https://doi.org/10.1145/2723872.2723882</mixed-citation></ref><ref id="scirp.93423-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Fink, J. (2014) Docker: A Software as a Service, Operating System-Level Virtualization Framework. Code4Lib Journal, 25, 29.</mixed-citation></ref><ref id="scirp.93423-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Combe, T., Martin, A. and Di Pietro, R. (2016) To Docker or Not to Docker: A Security Perspective. IEEE Cloud Computing, 3, 54-62. https://doi.org/10.1109/MCC.2016.100</mixed-citation></ref><ref id="scirp.93423-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Mouat, A. (2015) Using Docker: Developing and Deploying Software with Con-tainers. O’Reilly Media, Inc., Sebastopol.</mixed-citation></ref><ref id="scirp.93423-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Matthias, K. and Kane, S.P. (2015) Docker: Up &amp; Running: Shipping Reliable Con-tainers in Production. O’Reilly Media, Inc., Sebastopol.</mixed-citation></ref><ref id="scirp.93423-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Peinl, R., Holzschuher, F. and Pfitzer, F. (2016) Docker Cluster Man-agement for the Cloud-Survey Results and Own Solution. Journal of Grid Computing, 14, 265-282. https://doi.org/10.1007/s10723-016-9366-y</mixed-citation></ref><ref id="scirp.93423-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Seo, K.-T., et al. (2014) Performance Comparison Analysis of Linux Container and Virtual machine for Building cloud. Advanced Science and Technology Letters, 66, 105-111. https://doi.org/10.14257/astl.2014.66.25</mixed-citation></ref></ref-list></back></article>