A developer of Linux Containers

By Tracy Gonzales,2015-02-25 10:05
19 views 0
A developer of Linux Containers

    A developer of Linux Containers

    Tell you a secret: all the conversation how cloud tools into my application and linked with the world is still a mystery to me.However, as time goes on, I have come to realize that, know how to configure is the alpha and omega of large-scale machine and application developers must possess important ability, just like the process of becoming a professional musician.If you want to be a professional musician, of course, you need to know how to play a musical instrument, but, if you don't understand the studio work or don't know how to blend in a symphony orchestra, you also will be difficult to work in such an environment.

    In the world of software development, will your code into the world and write code are equally important.The conversation can do it very well.

    So, in order to set up a bridge between development and technical operation, I will introduce a new technology -- container technique.Why is the container?Strong evidence that the container is the next stage of machine virtualization: since the computer is no longer an item but a location.Come quickly and I approached the container together.

    In this article I will introduce the container behind, container technology and the concept of the difference between a virtual machine, it is the logic behind the structure and how to adapt to the application architecture, a simplified version of the Linux operating system how to adapt to the container system and how to use the mirror to create reusable containers.At the

    end of the article, I will introduce how to use the container to make your application in a short period of time.

    After the article I'll show you step by step process of container to an application instance, and the container for the application to create a host of the cluster method.I will also show use of Dies on the local system of the virtual machine or configure an example application on cloud service providers.

    Now, let's get started!

    The advantages of the virtual machine

    Container you want to know how to adapt to the whole architecture, first need to know the container of the predecessor: virtual machine.

    The virtual machine(VM) is a virtual computer software running on a physical computer, the computer is installed on a virtual machine is like buying a special computer: you can customize the number of CPU and memory and disk storage capacity.After configuration is complete, you can put the operating system and any support you need to virtual machine load of server and application.

    Virtual machine allowed to run multiple virtual machines on a single hardware host.Simple schematic diagram is as follows:

    Virtual machine to improve the investment performance of the hardware, you can buy a big and loud machine equipment, and then run on it a large number of virtual machines.You can also use database contains the virtual machine and a large number of custom applications of virtual machine (with version) as a cluster running at the same time.Won extend the limited hardware resources, as long as your host hardware allows cases, if you find that need more virtual machine, you can add.If you no longer need to virtual machine, the virtual organ will close and delete a virtual machine images.

    The limitations of the virtual machine

    But the virtual machine has its own limitations.

    When you press the above steps on a host creates three virtual machine.Host a total of 12 CPU, 48 gb of memory, 3 TB of storage space.Each virtual machine assignment 4 CPU, 16 gb of memory and 1 TB of storage space.So far, everything is normal, within the scope of the ability of the host configuration.

    Should note, however, a disadvantage.Host all the resources allocated to each virtual machine is special.No matter what this virtual machine is, will be assigned to 16 gb of memory.However, if the first virtual machine never use more than 1 GB of memory allocation, the rest of the 15 GB will be idle there.If the virtual machine to use it only assigned to the 1 TB 100 gb of storage space, so the rest of the 900 gb is wasted storage space.

    Because resources and classification, no fixed use assigned to each virtual machine resources.To a certain extent, therefore, returned to the virtual machine before - waste a lot of money on useless resource s.Another drawback of the virtual machine is running slow, so even if the virtual machine configuration automation, when need to quickly expand infrastructure, still have to play it online work such as to move the thumb.

    Container appearance

    Container is a think only itself in the running state of Linux program, only to the user specified command.At the same time, in the container, the container program has its own IP address.Important thing again: in the container, the container program is assigned an IP address.Once you have the IP address, within the host application has become a recognizable network resources.Then manager can send commands to the container, the container's IP address mapping to an open host IP address.For whatever purpose, once this mapping occurs, a container is a independent can access the network equipment, conceptually similar to the virtual machine.

    Again, the container is an independent Linux program, has its own IP address, so you can identify in the network.As shown in the figure below:

    A container and other applications to dynamically Shared hosting resources, cooperation way.If the container only need 1 gb of memory, it only use 1 gb of memory.If it need 4 gb of memory, it is only 4 gb.The same holds true in the use of CPU and storage space.The allocation of CPU, memory, storage space is dynamic, not static allocation, as a typical virtual machine.All these resources Shared by the container management.

    In addition, the container has the advantages of fast.

    On the whole, the advantages of the container can be summed up in: has the characteristics of the virtual machine independent and encapsulation, and compensate for the resource allocation for static shortcomings.And rapid load the memory capacity make it have better expand more performance of the container.

    The container managed, allocation and management

    Now, the host can run Linux version container has become necessity.Recently, on a host of an underlying operating system is more and more to the more popular, which mentioned aboveCoreOS.Of course there are many other underlying operating system, such asRed Hat Atomic HostandUbuntu Snappy

    All containers share under Linux operating system, in order to reduce the repeated and deployment container.Each container contains only a specific container due function.Show in the form of chart below:

    You can use the required components to configure your own container.There is a layer called container components.Mirror a layer is a container (in the following chapters, you will learn more knowledge about container mirror).General starting from the base layer and base layer is usually what do you want to the kind of operating system used in the container (container manager only provide you the required part of the operating system, not the host operating system).If you want to run other script files in the container, we need to build the container configuration and increase the layer.For example, want to run the Web server, PHP, and Python, need to configure the Apache.

    In addition, the layering is very flexible.If your application or service framework for PHP 5.2 container needed, would need to configure the corresponding container.If you have another application or service need PHP5.6 framework, also only use PHP 5.6 configuration corresponding container.It is not like a virtual machine, change the currently running version need to do a lot of configuration and installation steps.Use of the container, you just need in the process of container configuration file to define the layer.

    Before this, all containers versatility is controlled by a called container manager software.At present, the management software is one of the most popular

    containerDockerandRocket.Described above is a host, the host USES Docker to manage the container and use CoreOS operating system.

    Container with mirror at the same time

    When you will be a container for application packaging, but also established the corresponding image.A mirror image represents a container template, this template is the container's template you needed (I know, the container contains container, think about it).Images stored in the registry, the registry is cached on the network.

    Conceptually, for those who are familiar with Java, similar to the registryMavenLibrary, or similar to platformNuGetThe server.Create a container configuration file, in order to list all the image application.Using the container manager to generate a container, the container can include the application source code and resources downloaded from the container to the registry.For example, if your application is composed of a PHP file, container configuration file will allow you to get PHP runtime environment from the registry.Again, also can use container configuration files to that needed for the file system is copied to the container. The PHP file.Container manager application components can be encapsulated into a different container, in a container under the condition of manager, you can run this container on a host computer.

    The following figure shows that the container to create the process behind:

    Let's take a closer analysis under the picture.

    Here (1) indicates that there is a container configuration file, the file defines what containers you need, and how to build the container.When running on the host container, the container manager will read from the cloud in the registry configuration file image of the vessel.(2) add image to the layer of the vessel.In addition, if the composition of the mirror need other mirror, container manager to retrieve the image and add them to the layer.(3), the container manager will copy files into container you need.

    If you use a configuration services, for exampleDeisYou just build application container will exist in the form of image.(4) the configuration service can be deployed to the cloud provider that you selected.Common cloud provider is AWS and too.

    The container cluster

    As a result, we can say that in a good situation, the container than virtual machine provides an even greater degree of configuration flexibility and higher resource utilization.However, it's not all advantages.

    When a container together will become more flexible.Please keep in mind that different container corresponding to different IP addresses.Therefore, the container can be placed behind the load balancer, once do that, "game" will rise to a new level.

    You can run under load balancer containers to realize high performance cluster and high availability of computing.Here's an example:

    Let's talk about what you are doing resource intensive applications.Such as image processing program.Using such asDeisSuch as container configuration technology, you can create a new container image, the container mirror will include image processing applications and all the resources needed for the program.Then, you can under the load balancer of the host image deployment of one or more such container.Once the container mirror set up

    complete, you can use it as a host system after the collapse of the backup, and need more in the container cluster mirror to complete all work.

    Better news.In multiple mirror instance is added to the work environment, every time you do not have to manually configure load balancer.You can use the service discovery technology to make container load balancer automatic configuration so as to make the container holding the balance of usability.Then, once so, balancer will begin to a new node flow routing.

Report this document

For any questions or suggestions please email