Server virtualization refers to a layer between the operating system and hardware, called the hypervisor layer, the control hardware, on the host operating system, operating system OS in the form of file encapsulation operation, called Virtual machine, the main problem is the hardware utilization and flexibility of the problem, The common scenario is VMware vsphere,xen,kvm,hyper-v . Container virtualization refers to running application packaging as a process on the OS, application and application non-complete isolation, but lighter, more efficient, LXC and Docker can be referred to as container-level virtualization, the difference is that Docker can be understood as a beautifully packaged and more usable lxc, There are better interfaces and more perfect matching.
If Linux is likened to transportation, Docker is like a car engine, Docker containers are the equivalent of various parts of a car, Dockerfile is a car assembly shop, and Docker registry can be seen as a 4s store.
1. Introduction to Docker Virtualization Technology
Docker is an open-source application container engine that allows developers to package their applications and dependencies into a portable container, and then publish them to any popular Linux machine or virtualize them. "Docker" should be one of the hottest technologies of the 2014, and if you haven't heard it, then you're out, and the new leap will start in 2015. The goal of the Docker project is to implement a lightweight operating system virtualization solution. Docker is based on technologies such as Linux containers (LXC) and Cgroup.
2. Docker Virtualization Installation Configuration
The official Docker document says that Linux kernel are required to be at least 3.8, typically Centos7 or Ubuntu systems, and how does centos6.5 install it? To install the Docker software in the Centos6.x series, first turn off SELinux, and then you need to install the appropriate Epel source.
3, Docker common commands to explain
We all know that to Master Linux, the first is to be proficient in Linux commands, and to use it. And then today learning Docker virtualization is the same, we want to grasp the Docker technology faster, we have to skilled docker what the common commands, and the meaning of each command, so that we can lay the foundation behind the study.
4. Docker independent IP and container interconnection
Built-in Bridge (NAT) disadvantage: Need to support Service Registration/discovery, otherwise the host port allocation is difficult, prone to conflict. Because the ports exposed by each container are inconsistent, there is no way to use DNS in the front-end routing layer nginx configuration (proxy_pass). Port mappings are specified when the container is started and cannot be changed later. The test found that NAT does not support WebSocket. Self-built bridge network advantages: Each container has a separate IP, external services, such as Nginx+php,nginx+resin, can use the default 80 port because the container exposed port can use 80 port, so the front-end routing layer nginx configuration (proxy_ Pass) can be used in a DNS way.
5. Docker uses pipework to build an independent extranet IP
Docker provides an isolated intranet environment by default, and a DOCKER0 virtual network card is created at startup, each of which is connected to the Docker0 NIC. The IP segment of DOCKER0 is 172.17.0.1, if you want the container to be accessible to other machines on the same network segment as the host, you must map a port to the host port when you start Docker. So if people will find it troublesome, and in the enterprise is not so used, weaker. You should know that the KVM Bridge network is very convenient, in fact, Docker is more convenient, at least not the own bridge, Last course we explained the implementation of Docker containers under centos6.5, and today we will explain CENTOS7 if you quickly implement a Docker container bridging network and assign an extranet IP to the container.
6. Docker Build Tomcat Environment
Tomcat is a servlet container developed by the Apache Software Foundation's Jakarta Project to support Servlet and JavaServer Page (JSP) according to the technical specifications provided by Sun Microsystems. Tomcat itself is an HTTP server that can be used alone, and Apache is an HTTP server written in the C language. Tomcat is primarily used to parse the JSP language. Currently the latest version is 8.0.
7. Using Dockerfile for Docker container management
Dockerfile is an image representation that can be dockerfile to describe the steps to build a mirror and automatically build a container. All Dockerfile command formats are: instruction arguments Although the instruction ignores case, it is recommended to use uppercase.
8, Dockerfile Enterprise case explanation and actual combat
Dockerfile is an image representation that can be dockerfile to describe the steps to build a mirror and automatically build a container. All Dockerfile command formats are: instruction arguments Although instruction ignores case # author info maintainer jfedu.net # Run command executes any command in the image specified above run yum install passwd OpenSSL openssh-server-y RUN Echo & #39;123456& #39; | passwd--stdin root RUN sed-i & #39;/^session\\s\\+required\\s\\+pam_loginuid.so/s/^/#/& #39; /etc/pam.d/sshd
9. Docker Backup and disk expansion
The default space for Docker containers is 10G, and if you want to specify the size of the default container (specified when you start the container), you can specify it in the Docker configuration file via the Dm.basesize parameter, for example: docker-d--storage-opt dm.basesize =20G is the specified default size of 20G, the specific parameters can be referenced https://github.com/docker/docker/tree/master/daemon/graphdriver/devmapper
10. Docker build MySQL database server
In Docker virtualization, how do we build our MySQL database server? The answer is simple, we can be dockerfile to generate a MySQL image and start running.
11. Docker build Nginx High Performance Web server
First need to install Pcre Library, and then install Nginx: #安装pcre支持rewrite库, you can also install the source code, note * When installing the source code, specify Pcre path to extract the path of the source, not the path of the compilation, otherwise will error (MAKE[1]: * * * [/usr/ Local/pcre/makefile] Error 127 errors)
12. Docker Build Lnamp Architecture Configuration
Lnamp (linux+nginx+apache+mysql+php) architecture is favored by many IT companies, instead of the original thought of a good lnmp (linux+nginx+mysql+php) architecture, then we say Lnamp what is the advantage of it, You have to start with the pros and cons of Nginx and Apache. Nginx processing static file ability is very strong, Apache processing dynamic file is very strong and stable, the two integrated in one, performance improved many times. Perhaps a lot of Linux SA in the LNMP operation, you will find that PHP (FastCGI) mode will appear some 502 error phenomenon, because of the nginx+php (FastCGI) combination of instability caused by the cause.
13, Docker automation script management One
With this chapter, you can quickly manage your own containers, automate the installation and configuration of Docker virtualization and bridging networks, and use the pipework software to configure our container IPs. Able to implement a simple management of the container. #!/bin/bash #auto install Docker and Create VM #by wugk 2016-01-05
14, Docker automation script management two
The goal of the Docker project is to implement a lightweight operating system virtualization solution. Docker is based on technologies such as Linux containers (LXC). On the basis of LXC, Docker has been further encapsulated, so that users do not need to care about the management of containers, making the operation easier. User-operated Docker containers are as simple as operating a fast, lightweight virtual machine. The following contrasts the differences between Docker and traditional virtualization (KVM, Xen, etc.), where containers are virtualized at the operating system level, directly reusing the local host's operating system, while the traditional approach is to virtualize their own systems on a hardware basis and then deploy related app applications on the system.
Do you really know about Docker virtualization?