Summary of practical tips for Docker container virtualization

  • 2020-05-17 07:03:40
  • OfStack

Server virtualization refers to the addition of a layer between the operating system and the hardware, called hypervisor layer, to control the hardware, to host the operating system, the operating system os in the form of file packaging operation, known as the virtual machine, the main solution is the problem of hardware utilization and flexibility, common solutions for vmware vsphere, xen, kvm, hyper-v... Container virtualization refers to the packaging of applications in the form of processes on os, which is not completely isolated between applications, but is lighter and more efficient. Both lxc and docker can be called container level virtualization. The difference is that docker can be understood as lxc, which is more user-friendly and has a better interface and a more complete set.
If we compare Linux to transportation, Docker is like a car engine, Docker container is like various parts of a car, Dockerfile is an automobile assembly shop, Docker registry can be regarded as a 4s shop.

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 release them to any popular Linux machine, as well as virtualization. "Docker" should be one of the hottest technologies of 2014, if you haven't heard of it, then out, which will make a new leap in 2015. The goal of the Docker project is to implement a lightweight operating system virtualization solution. Docker is based on Linux container (LXC), Cgroup and other technologies.

2. Docker virtualization installation configuration

The docker official document requires Linux kernel to be at least 3.8 and above. Generally, Centos7 or Ubuntu system is usually used. How to install centos6.5? To install the docker software in the Centos6.x series, first close selinux and then install the corresponding epel source.

3. Explanation of Docker common commands

Everyone knows that to master Linux well, the first thing is to master Linux command and use it. However, today's learning of docker virtualization is also a similar one. If we want to master docker technology faster, we need to be familiar with the common commands of docker and the meaning of each command. Only in this way can we lay a foundation for our future learning.

4. Docker independent IP and container interconnection

Built-in bridge (nat) disadvantages: need supporting service registration/discovery, otherwise port allocation on the host is difficult and easy to conflict. Because each container is exposed to different ports, dns cannot be used in the front-end routing layer nginx configuration (proxy_pass). Port mapping should be specified at container startup and cannot be changed later. Tests found that nat does not support websocket. The advantages of self-built bridge network: each container has a separate ip to provide external services, such as nginx+php, nginx+resin, and can use the default port 80. Since the container exposure port can use port 80, the front-end routing layer nginx configuration (proxy_pass) can use the mode of dns.

5. Docker USES PipeWork to build IP

By default, docker provides an isolated Intranet environment. At startup, a virtual network card of docker0 is created, and each container is connected to the docker0 network card. The ip segment of docker0 is 172.17.0.1. If you want the container to be accessed by other machines in the same network segment as the host, you must map a port to the host port when you start docker. So if you're going to find it troublesome, and it's not used in the enterprise, it's weak. You should know that the KVM bridge network is very convenient, in fact, docker is also convenient, at least it is not a built-in bridge. In the last class, we explained the implementation method of docker container under centos6.5. Today, we will explain how to quickly implement docker container bridge network under centos7 and assign external network IP to the container.

6. Docker builds Tomcat environment

Tomcat is an Servlet container developed by the Jakarta project under the Apache software foundation. According to the technical specifications provided by Sun Microsystems, Servlet and JavaServer Page (JSP) are supported. Tomcat itself is also an HTTP server, which can be used independently. Tomcat is mainly used to parse the JSP language. The latest version is currently 8.0.

7. docker container management using Dockerfile

Dockerfile is a representation of an image, which can be used to describe the steps to build an image and automatically build a container. All Dockerfile command formats are: INSTRUCTION arguments although the directive ignores case, it is recommended to use uppercase.

8, DockerFile enterprise case explanation and actual combat

Dockerfile is a representation of an image, and the steps to build the image can be described by Dockerfile, and a container can be automatically built. All Dockerfile commands are: INSTRUCTION arguments although the directive ignores case # author information MAINTAINER JFEDU.NET # RUN commands will execute any command in the image specified above. 123456 the & # 39; | passwd --stdin root RUN sed i; / ^ + required session \ \ s \ \ \ \ s \ \ + pam_loginuid so s / # ^ / / & # 39; / etc pam d/sshd

9. Docker backup and disk expansion

The default size of the docker container is 10G. If you want to specify the size of the default container (specified when the container is started), you can do this in the docker configuration file with the dm.basesize parameter, for example: docker d - storage - opt dm. basesize = 20 G is to specify the size of the default is 20 G, specific parameters can be reference https: / / github com docker/docker/tree/master/daemon/graphdriver/devmapper

10. Docker builds the Mysql database server

How do we build our MYSQL database server in docker virtualization? The simple answer is that we can use dockerfile to generate the mysql image and get it up and running.

11. Docker builds Nginx high-performance web servers

First need to install pcre library, and then install Nginx: # installation pcre support rewrite library, also can install the source code, note * installation source, pcre specified path to unpack the source path, rather than a compiled path, otherwise an error (make [1] : * * * / usr local/pcre/Makefile Error 127 error)

12. Docker builds the LNAMP architecture configuration

LNAMP(Linux+Nginx+Apache+Mysql+PHP) architecture is favored by many IT enterprises, replacing the LNMP(Linux+Nginx+Mysql+PHP) architecture. What are the advantages of LNAMP? Nginx has a strong ability to handle static files, while Apache has a strong and stable ability to handle dynamic files. Many Linux SA may find 1 502 error in PHP (FastCGI) mode when they are engaged in LNMP operation and maintenance, which is caused by the unstable combination of Nginx+PHP (FastCGI).

13. Docker automated script management 1

Through the study of this chapter, you can quickly manage your own containers, realize the automatic installation and configuration of docker virtualization and bridge network, and use the software pipework to configure our containers IP. Be able to achieve a simple container management. #! /bin/bash #auto install and Create VM #by wugk 2016-01-05

14. Docker automatic script management 2

The goal of the Docker project is to implement a lightweight operating system virtualization solution. The Docker is based on technologies such as the Linux container (LXC). On the basis of LXC, Docker is further packaged to make it easier for users to care about the management of containers. The user operates the Docker container as easily as a fast, lightweight virtual machine. The differences between Docker and traditional virtualization (KVM, XEN, etc.) are compared below. Containers realize virtualization at the operating system level and directly reuse the local host operating system, while the traditional way is to virtualize their own system on the basis of hardware, and then deploy relevant APP applications on the system.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: