Docker containers and virtual machines What is the difference?

The first chapter  http://virtual.51cto.com/art/201805/572135.htm

Docker containers and virtual machines What is the difference?

Docker container is a virtual environment, you can executable files, configuration files, and everything else you need documentation to be packed into this container, and publish and apply to any platform. For example, you use Python developed locally a website background, after the completion of development and testing, you can Python3 and its dependencies, Flask and its various plug-ins, Mysql, Nginx and other packaged into a container, then deploy to any of you want deployed to the environment.

The main problem to solve Docker

Taiwan has developed after the experience of the students, we must encounter the following problems:

Program development environment to run properly, but deployed to a production environment, but frequent situation;

Suppose a program to deploy in the customer's environment, although deploy in their own environment, authentication is successful, but always worried about the lack of certain necessary libraries on the client's environment, or some version of a file does not meet the requirements;

So, with docker, these problems will cease to exist.

What is the Docker

Docker container is a virtual environment, you can executable files, configuration files, and everything else you need documentation to be packed into this container, and publish and apply to any platform. For example, you use Python developed locally a website background, after the completion of development and testing, you can Python3 and its dependencies, Flask and its various plug-ins, Mysql, Nginx and other packaged into a container, then deploy to any of you want deployed to the environment.

If not well understood, we then let the container analogy.

Container solve the problem? In a big ship, the goods can be placed up regular. And a wide variety of goods are standardized containers, will not affect each other between the container and the container. So I do not need special transport ship and ship the fruit of the specialized transport of chemicals. As long as these goods in containers properly packaged, then I can use a ship them all away.

docker is a similar concept. We can run multiple containers docker unrelated to each other on a single machine, each container is equivalent to a container.

Docker in a few basic concepts

  • Mirroring

Mirroring can be understood as a bunch of static files

  • container

Example of a container is run up after the mirror. The container is like a mirror in the class in object-oriented programming in object.

  • warehouse

Mirroring the needs of local save, this place is warehouse

The difference with traditional virtualization

Here we talk about the way traditional virtualization.

We see that traditional hardware virtualization is standing on the basis of the physical resources, the more virtual OS, and then build a relatively independent environment for running programs on the basis of the OS, and Dokcer is a virtual OS on the basis of clearly Dokcer much more lightweight, so its resource consumption, performance overhead compared to traditional virtualization has a significant advantage.

Silver Fox Technology

CCTV network engineer 04-13 01:37

Practitioners in the IT industry for many years, are also considered cloud computing era from watching from physical servers to virtual era, but also ready to enter the Docker era, as the next generation of virtualization technology, Docker is changing the entire industry development, testing, deployment applications, As virtualization technology and docker technology in the end what is the difference, to analyze below.

01 What is virtualization?

As the name suggests, virtualization technology is the technology of virtual physical resources in some form of resource pools, and there are more than a virtual multi-virtual one in two forms, such as a personal computer to install Vmware software, you can install additional software on the system Win, MacOS , Linux systems, to achieve a computer / notebook carries the advantage of multiple systems, the current Apple notebook users dual system solutions are based virtual machine, ordinary Windows users may not demand, and technical personnel is essential prerequisite software a.

 

From the business perspective, a more virtual as the main form, that is, the number of physical servers virtualized cluster, forming a pool of resources, create a variety of different virtual machines on this resource, flexible deployment.

02 What is the Docker

In fact, docker and virtualization technologies like, but there are a number of different points, on the one hand, two technical level, the virtual machine is usually the underlying hardware Hardware support, upper management system is a virtual Hypervisor layer, open a different VM traffic in the upper, If these services need to be isolated, we need to start each VM guest operating system, consuming resources.

 

Docker is completely different, the underlying hardware and Host OS support system, such as Windows / MacOS / Linux, shuffled around the middle of the bloated system, but in Docker daemon instead of the upper establish different containers, different applications packaged in a different image container, they are isolated from each other.

The difference between virtualization and docker of 03

docker compact design, deploy, migrate fast, efficient operation, independent of each other between applications, managers can see the contents of all containers, virtualization technology more bloated, no matter what applications you need to create a new system, and are not in accordance with application isolation, but according to the isolation system, the system administrator can not see inside information.

For example, Docker is a variety of APP mobile phone, only one system you can download the application they need, but virtualization technology equivalent of your iPhone to install a large software, install the software on the Android system, Meizu system etc., but also all kinds of applications installed on each system, more trouble.

But the two are not absolutely good or bad, mainly to see the scenario, choose different solutions according to different needs.

 

The second  http://m.elecfans.com/article/648468.html

Docker is written Golang, since its launch in 2013, more and more attention of developers. If you are concerned about the latest technological developments, then you must have heard Docker. Whether cloud service or micro-services (Microservices), more and more manufacturers are beginning to Docker as on infrastructure automation tools. So what is the Docker? Docker with traditional virtual machine What is the difference? Why adopt Docker? How to use the Docker?

In this paper, it is for the above mentioned problems, a brief introduction to Docker.

What is the Docker

Docker is an open source application container engine.

Docker lets you since all application software and packaging it into a standardized unit of software development.

All documents Docker container will run the installation software, and it required (the code is running, system tools, system libraries) packaged together, which ensures that no matter what kind of operating environment, always run in the same way . If the Java virtual machine as "write once (Write once, run anywhere)", while Docker was "build once, run everywhere (Build once, run anywhere)".

Docker is a "container as a Service" (Docker Containers as a Service, referred CaaS), enables developers and IT operations teams can use to build, distribute, run more agile and controllable.

In a nutshell: Docker is for developers and system administrators to build, publish, and run an open platform for distributed applications. The platform consists of Docker engine (a portable, lightweight runtime and packaging tool) and Docker Hub (a shared application and cloud service workflow automation) and other components. Docker can quickly assemble applications from components and eliminates the development problem of friction between quality assurance and production environments. As a result, IT departments can quickly publish, no matter which application is running in a virtual machine notebook computers, data center, or any of the cloud, its operation and the results are the same.

Let us look at Docker's Logo. Obviously, this is a whale, it is holding a number of containers. We can host may as whale, the container can be seen as isolated containers, each container contains its own applications. This Logo is simply a wonderful metaphor!

Docker's advantage

Lightweight: All containers share the same operating system kernel on a machine, so they start immediately, and more efficient use of memory. Image is built from a hierarchical file system so they can share a common file that downloads and Image disk usage more efficient.

Open: Docker container is a standards-based development, allowing the vessel to run in mainstream Linux distributions and Microsoft operating systems as all the infrastructure.

Security: container enables applications isolated from each other, and infrastructure while providing an extra layer of protection for your application.

Docker difference between the virtual machine

Container virtual machine has similar advantages isolation and resource allocation, but different architectural approaches the container to be more portable and efficient.

Virtual machine architecture

Each virtual machine including applications, the necessary binaries and libraries as well as a complete client operating system (Guest OS), although they are separated, they share and use of hardware resources of the host, need nearly the size of a dozen GB.

Container architecture

Container including the application and all of its dependencies, but shared kernel and other containers. They run on the host operating system to form a separate user space process. They are not dependent on any particular infrastructure, Docker containers can be run on any computer, on any infrastructure and any cloud.

Docker containers use the LXC, management utilizes namespaces do permission control and isolation, cgroups to allocation of resources, and also by aufs to further improve the resource utilization of the file system, and these technologies are not Docker original.

LXC

The difference LXC virtual machine is that it is an operating system-level virtualization environment, rather than hardware virtualization environment. They all do the same thing, but LXC is operating system-level virtualization environment, virtual environment has its own process and network space, instead of creating a complete mature virtual machine. Therefore, a virtual operating system LXC have minimal resource requirements, and takes only a few seconds.

As you can see in the figure below, the left is LXC virtual Ubuntu, the default installation using 11 MB in size.

Docker's relationship with Microservices

Microservices (micro-services) depend on "infrastructure automation", while Docker is the "infrastructure automation" weapon. It can be said is hot, to a certain extent on the Docker also led to the rise of micro-service architecture, and extensive application of micro services also contributed to the Docker prosperity. It can be said that the two complement each other.

An introduction to micro services, venue to be "brief Microservices (micro-services)."

http://www.importnew.com/24651.html

Why Docker

Develop more agile: Docker allows developers are free to define the environment, to create and deploy applications faster, easier, IT operation and maintenance personnel to quickly respond to changes and more flexibility.

More manageable: Docker enables developers to save the code from the application infrastructure to help manage IT operation and maintenance people have a standard, secure, scalable operating environment.

High Portability: Docker allow freedom of choice, which can be from a laptop to a team, from private to public cloud infrastructure provider.

In this way, you can focus on the development and application of other tedious things to Docker do it.

How to use the Docker

This is really a big topic, if fully set forth enough to write a book. Fortunately, our aim is to make the entry popularity, so we simply talk about Docker installation, use, and basic common commands.

Docker installation

Recommended to install the linux environment Docker, window environment to build more complex and error-prone, use Centos7 + yum install Docker environment is very convenient.

Docker package already included in the default CentOS-Extras software source inside. So you want to install docker, yum only need to run the following command:

yum install docker

After installation is complete, use the following command to start the docker services, and set it to boot:

service docker startchkconfig docker on

LCTT Annotation: sysv employed herein old syntax, such as the use of new syntax CentOS 7 systemd supported, as follows:

service docker startchkconfig docker on

test

docker version

Enter the above command returns the version information docker prove docker successful installation.

Hello World

Below, we adopted the most simple image file "hello world", feel Docker.

Because the domestic official connection Docker warehouse is very slow, so we will use the accelerator Docker China in daily use. Docker mirrored by official accelerate, China, users can quickly access the most popular Docker image. The mirror is hosted mainland China, local users will now enjoy faster download speeds and greater stability, enabling more agile develop and deliver Docker applications.

Docker Chinese official mirror acceleration can be accessed by registry.docker-cn.com. The image library contains only popular public image, private image from the still image library in the United States pull.

Docker modify system configuration file corresponding to, the following:

vi /etc/docker/daemon.json#添加后{ "registry-mirrors": ["https://registry.docker-cn.com"], "live-restore": true}

Run the following command to grab the image file from the warehouse to the local.

docker pull library/hello-world

The above code, docker image pull crawl image file commands. library / hello-world is the location of the image file inside the warehouse, where the library is a set of image files are located, hello-world is the name of the image file.

After the crawl is successful, you can see the image files in the machine.

Display results docker images # REPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/hello-world latest f2a91732366c 3 months ago 1.848 kB

Now, run the image file.

docker run hello-world#显示结果Hello from Docker!This message shows that your installation appears to be working correctly....

After the output of this prompt, hello world will stop running, the container is automatically terminated. Some containers are not automatically terminated because the service is provided, such as Mysql mirroring.

Common Commands

In addition to the above Docker had ordered us to use, Docker and some other commonly used commands.

Mirrored pull docker

docker pull image_name

See image on the host, Docker image stored in / var / lib / docker directory:

docker images

Remove Mirror

docker rmi docker.io/tomcat:7.0.77-jre7 or docker rmi b39c68b7af30

View the current vessel which is running

docker ps

View all containers

docker ps -a

Start, stop, restart vessel command:

docker start container_name/container_iddocker stop container_name/container_iddocker restart container_name/container_id

After starting a container background, if you want to enter into this container, you can use the attach command:

docker attach container_name/container_id

Command to delete container

docker rm container_name/container_id

Docker view the current system information

docker info

Download an image from the Docker hub:

docker pull centos:latestdocker pull centos:latest

Docker pull centos will perform this warehouse Centos following all downloaded to the local repository mirror

Guess you like

Origin www.cnblogs.com/maji233/p/11032392.html