Containerization of Server Services
Containerization of Server Services
doi:10.2478/mape-2020-0028
Date of submission to the Editor: 03/2020
Date of acceptance by the Editor: 06/2020
MAPE 2020, volume 3, issue 1, pp. 320-330
Adam Muc
ORCID ID: 0000-0002-9495-087X
Tomasz Muchowski
ORCID ID: 0000-0002-0200-7041
Gdynia Maritime University, Poland
Albert Zawadzki
ORCID ID: 0000-0002-7516-0100
Polish Naval Academy of the Heroes of Westerplatte, Poland
Adam Szeleziński
ORCID ID: 0000-0003-2842-0683
Gdynia Maritime University, Poland
INTRODUCTION
The growing popularity of remote working requires changes in the network
infrastructure of enterprises. The changes also include the way web
applications, databases and other network services are hosted. In local
networks, in case of port conflicts, web applications and network services are
hosted on separate servers. Separate servers also often host applications that
rely on common dependencies but require different configuration. If enabling
remote access to these services is needed, it may be necessary to perform port
forwarding or equip servers with global IP addresses. If network traffic is allowed
from an external network, the target device must be adequately secured, e.g.
with firewall and antivirus software. This must be done for every device that can
be accessed from an external network. This significantly increases the workload
of the network administrator, as it is his task to maintain the server operating
systems by updating and maintaining the enabled security measures. As the
number of devices available from the external network increases, so does the
probability of security failures and allowing data leakage or violation of the
device's operating system by an unauthorized entity. This problem cannot be
solved by purchasing a VPS server, as port collisions also occur in this case.
The solution to the problem may be the use of virtualization. A virtual machine
has its own operating system and, with an appropriate network configuration it
also has its own IP address in the local network (Portnoy, 2016). Network traffic
can be redirected to virtual machines using port forwarding. Alternatively, the
network cloud, i.e. Amazon AWS, can be used to create virtual machines with
global IP addresses, in that case port forwarding is not necessary. However, the
costs of network clouds can be high because the operating systems of each
virtual machine create a resource overhead on the cloud. This situation also
applies to the local server, whose resources will be used by the operating
systems of the virtual machines it maintains. In addition, each of the virtual
machines must be adequately secured so that they are not infected with
malware or taken over by an unauthorized entity (Palmer, 2017; SUSE LLC,
2018).
A better solution may be to containerize the application. Containers create an
isolated environment, but operate on the operating system of the parent device.
Containerization software also allows to create virtual network adapters, which
are used to isolate network connections made by containerized applications
from the parent operating system and parent local network. This means that
containerized applications can use the default network ports without interfering
with other containerized applications if they operate on another virtual network
infrastructure. They also do not interfere with the services of the host operating
system. Virtual networks allow for port forwarding of the virtual network adapter
so that the host operating system can access and share the container-
maintained services on the local and external networks (Dua et. all, 2016;
Poulton, 2017).
Containerization of services and applications completely solves port collisions
and collisions of required configuration of common dependencies. An example
of a containerization program is Docker. It is a program created in 2011 using
Go programming language. Docker has gained a well-deserved popularity in the
last two years and started to be used in many companies dealing with
programming, DevOps and professional maintenance of network services
(Container Journal Website, 2020). However, this software is not difficult to
configure and can also be successfully used in small enterprises without IT
support.
TEST BECH
Test server
The Docker engine can work on both Windows and Linux distributions because
it allows containerization of software for both systems. It is not possible to run
Linux containers natively on Windows and vice versa. The containers are linked
to the operating system and cannot be run on a system incompatible with them
(Nickoloff and Kuenzli, 2019; Poulton, 2017). By default, containers are built for
use in Linux distributions, because containers built this way are more efficient
than their Windows counterparts. The software native to Windows systems can
also be containerized, but must be run on a device with Windows operating
system installed (Stoneman, 2019).
Although native intersystem container use is not possible, Docker for Windows
allows creating a lightweight Hyper-V virtual machine that will support Linux
containers and provide access from the parent system to the opened ports of
322 Multidisciplinary Aspects of Production Engineering – MAPE vol. 3, issue 1, 2020
In the Figure 3 above a Dockerfile file can be seen – it is a file that contains
instructions for containerization process of the created application. The content
of the Dockerfile is shown in the Figure below.
As it can be seen in the figure above, this file contains a description of container
image properties and a series of instructions. This image will be built from the
openjdk:8-jdk-alpine image, because the JRE (Java Runtime Environment) is
required to run an application created in Java. The selected OpenJDK image is
based on the Alpine Linux image. Alpine Linux is a minimalist Linux distribution,
occupying approximately 8MB of space (Alpine Linux Distribution Website,
2020), making it ideal for containerization use. The OpenJDK base image is
open source and publicly available in the docker hub registry. It contains a ready
to use and configured environment for Java applications. The image is then
configured using a series of instructions written in the Dockerfile. A new user
group is added and a new user is placed in it. This user will be used to run the
application in the container. This is an optional step, but it is worth taking care
that the application does not run with administrative privileges, as this may be a
potential security breach. Then an argument is added. The arguments are
variables that can be used in further lines of configuration code. In this case, the
created argument is the path to the *.jar file, which should be placed in the
container. In the next instruction, the file specified by the argument is copied to
the container and saved under the app.jar name. Then the entry point is defined,
which specifies what action the container should perform at the start. In this case
it is going to launch the app.jar file. The created Dockerfile is ready for optimal
test application containerization.
Before containerization, the application must be built, in case of Java
applications, the resulting file is a file with *.jar extension. The Maven tool was
used to build the test application. The next step is to issue a command to create
container image. This operation is shown in the Figure 4 below.
A container image will be created, which can be used to launch a new container
with the test application. The image list can be displayed using the docker image
list command. The newly created image is only available on the computer on
which it was created. The image can be uploaded the docker hub registry to be
used on other devices as well. However, it is worth mentioning that the docker
hub is publicly accessible to everyone. If the application is intended for specific
company use, it may be necessary to create a private registry. In this case, one
of the authors' account in the docker hub registry was used. The publication of
the image is an optional activity. The created image can be used locally to create
containers. Publication is necessary if containers with the application will be
created on other devices as well, because they must have access to the image
in order to create a container. The following Figure 5 shows the process of
displaying available images, publishing an image and creating a container
based on the created image.
As it can be seen in the figure above, a container was created and given the
name BussinessAppTest. The application uses port 8080 by default, but the
container's traffic on this port has been redirected to port 80 of the parent
system. This means that the parent system can display the application's network
content because the traffic was redirected to its interface on port 80. As the
containerized application is a web application, a web browser should be used to
display its network content. The following Figure 6 shows an attempt to display
the web content of a containerized web application.
Fig. 6 Test of access to the web application from the server’s web browser
As it can be seen in the Figure above, the network content of the containerized
application is correctly forwarded to the network interface of the parent operating
326 Multidisciplinary Aspects of Production Engineering – MAPE vol. 3, issue 1, 2020
system. This means that if the server has a public IP address and the firewall is
properly configured, the application is also available on the external network. In
this case, the server does not have a public IP address, but port forwarding was
used to redirect incoming network traffic from the external network to a given
port of the server's network interface. A second test device was placed in the
external network and was used to connect to the router’s DNS address. The
operation is shown in the Figure 7 below.
Fig. 7 Test of access to the web application from the external network
As it can be seen in the figure above, the operation was successful. It means
that the application has been properly containerized and properly isolated from
the parent system.
The creation process must always be verified. The following Figure 9 shows the
process of verifying whether an virtual adapter, volume and containers have
been created.
As it can be seen in the figure above, the operation of creating a virtual network
adapter, virtual volume and containers was successful. It should also be noted
that the virtual adapter ports for the DBMS container were not forwarded. This
means that communication with this container is only possible from within the
virtual network infrastructure. This provides complete isolation and guarantees
that only the containerized application can access its dependency.
As the virtual adapter port for the container with the web application has been
forwarded, it is available from the parent operating system. It should be noted
328 Multidisciplinary Aspects of Production Engineering – MAPE vol. 3, issue 1, 2020
that the application occupies the 8080 port of the parent system and the
application from the first example occupies the 80 port. By default, both
applications work on port 8080 and there would be a collision, but thanks to
containerization and appropriate port forwarding, both applications can work
simultaneously. The following Figure 10 shows a connection test to the
containerized web application.
As it can be seen in the figure above, the application returns the collection
contents from the database. The test application is an application that removes
the collection when the page is loaded, and then creates it again by creating
new documents. Then the data is send and displayed to the user. This is a
typical application testing the correctness of connection to the database and the
functionality of CRUD operations (Create, Read, Update, Delete). The following
Figure 11 shows the source code fragment responsible for testing the database.
The same Dockerfile as the previous application was used to create an image
of the web application. By using arguments, it is universal for applications
created in Java programming language. By creating an appropriate Dockerfile it
is possible to containerize most application and its dependencies.
CONCLUSION
Containerization consists in isolating the software from applications installed in
the parent operating system. Containerized software does not cause collision of
used network ports and dependency configuration like DBMS configuration.
Appropriate creation of Dockerfile configuration file allows to create container
Engineering and Technology 329
image of most applications. Using the image containers can be created. Images
can be used locally or published to a registry. The Docker Hub is the largest
container registry, but as it is a public registry, use of private registry may be a
better fit for company applications container images.
Software isolation solves the problem of collisions in a simple and cost effective
way. It is better than alternatives such as using virtual machines because virtual
machines create an overhead of used resources by the necessity of having an
operating system installed. This also means extra work with maintenance.
Containerization solves this problem. Containers are also safer to use, as they
do not require separate security features. A well-secured server's host operating
system will prevent the integrity of the containers from being compromised or
data stolen from the containerized application. Due to numerous advantages in
comparison with virtual machines, the containerization technology can be used
in companies that are equipped with servers that host network services.
REFERENCES
Carter, T. (2017) Docker and virtual machines. Independently published
Dua, R. and Kohli, V. and Konduri, S.K. (2016) Learning Docker Networking.
Birmingham: Packt Publishing.
Alpine Linux Distribution Website. About section [online]. Available at:
https://alpinelinux.org/about/ [Accessed 1 June 2020].
Container Journal Website. Using Google trends to chart Docker’s rise to fame [online].
Available at: https://containerjournal.com/features/using-google-trends-chart-
dockers-rise-fame/ [Accessed 1 June 2020].
Docker Documentation. Docker Desktop for Windows [online]. Available at:
https://docs.docker.com/docker-for-windows/install/ [Accessed 1 June 2020].
Microsoft Website. Windows Documentation – WSL2 [online]. Available at:
https://docs.microsoft.com/en-us/windows/wsl/wsl2-index [Accessed 1 June
2020]
Leszko, R. (2019) Continuous Delivery with Docker and Jenkins, 2nd Edition.
Birmingham: Packt Publishing.
Nickoloff, J. and Kuenzli, S. (2019) Docker in Action, 2nd Edition. Manning Publications.
Palmer, M. (2017) Hands-On Microsoft Windows Server 2016, 2nd Edition. Boston:
Cengage Learning.
Portnoy, M. (2016) Virtualization Essentials, 2nd Edition. New York: Sybex.
Poulton, N. (2017) Docker Deep Dive. Independently published.
Stoneman, E. (2019) Docker on Windows, 2nd Edition. Birmingham: Packt Publishing.
SUSE LLC (2018) SUSE Linux Enterprise Server 12 - Virtualization Guide. Suwanee:
12th Media Services.
330 Multidisciplinary Aspects of Production Engineering – MAPE vol. 3, issue 1, 2020