Docker learning Summary-Comparison of features between Docker and Vagrant

Source: Internet
Author: User
Tags virtual environment

Docker learning Summary-Comparison of features between Docker and Vagrant

The following content is discussed in stackoverflow by Mitchell Hashimoto and Solomon Hykes. In this case, the two parties have elaborated on the characteristics and scope of use of vagrant and docker, which makes sense for a deep understanding of vagrant and docker. Therefore, I have translated this question for your discussion and study.

As the author of vagrant, Mitchell has been immersed in the DevOps world for many years and has been engaged in many virtualization software similar to docker. He is currently engaged in many use cases of vagrant and docker, so he sees how the two work together.

He believes that using docker can simplify many things if developers use the host independently. In such scenarios, there is no difference between using docker and vagrant. So he discussed more complex scenarios. In these complex scenarios, there are some differences between docker and vagrant.

The original article is as follows:

It is inappropriate to directly compare vagrant with docker regardless of the scenario! In some simple scenarios, the two products have repeated functions, but in more scenarios, they cannot replace each other. In fact, vagrant is more abstract than docker, so it is inappropriate to directly use vagrant compared with docker. It seems more appropriate to compare vagrant with Boot2Docker (the smallest kernel running docker.

To support development, vagrant has started many applications and services when starting the virtual machine environment. Vagrant can run on VirtualBox and VMware (docker cannot run ). Vagrant can also run in cloud environments such as AWS and OpenStack. Even if you use a docker container, vagrant is fine. Vagrant can automatically install, pull down, build, and run Docker containers.

For example, in vagrant V1.6, vagrant integrates docker-based development environments. Therefore, Vagrant can provide docker services on windows, mac, and linux.

Vagrant does not want to replace docker. On the contrary, it also contains some features of docker.

If we compare vagrant and docker logically, then:

1. docker can only execute the container defined by docker.

2. docker lacks flexible isolation solutions (docker can only run in a Linux host environment ).

If we compare Production with CI, docker cannot compare with vagrant: Vagrant does not have the preceding constraints, and docker must rely on them.

If your project must use a Docker container and can only be deployed on a Linux host. Docker is indeed a good choice at this time. In addition, I cannot see the advantages of using docker. On the contrary, you have wasted many advantages of vagrant:

    • Vagrant supports multiple virtual environments, such as VirtualBox, VMware, AWS, and OpenStack. Vagrant can run smoothly regardless of the virtual environment you use. If you use Docker, you can install docker in vagrant.
    • Vagrant can reduce project complexity. To put it another way: you only need to consider how to execute your project, whether it is docker or anything else. In the future, if there are docker competitors, vagrant can run it smoothly.
    • Vagrant can run in multiple host environments, such as windows (XP or later), MAC (10.5 or later), and Linux (2.6 or later ). If you use docker, vagrant can also run your docker on top of the three operating systems.
    • Vagrant can better configure network and file sharing. For example, vagrant can configure static IP addresses and port data forwarding for a VM. Vagrant can be used to complete the configuration, whether you use VirtualBox or VMware. For file sharing, vagrant provides multiple file mounting solutions for your consideration. If you use docker, you need to do all these things yourself.
    • Vagrant 1.6 integrates docker-based development environments. Therefore, in MAC and Windows environments, vagrant automatically starts a virtual machine to execute docker, thus achieving cross-platform docker. Vagrant completes operations such as networks and files.

The following two points show how docker can replace vagrant:

    • "Docker requires a small amount of data to be moved" Indeed, Docker has this feature (it should refer to the UFS used by Docker, resulting in a small amount of data required for every docker change-I guess ). However, when you use docker in every project or in every project now and in the future, you will find that there are a lot of data generated by docker. If you use vagrant, you only need to move it once. (Original article: "It is less moving parts"-Yes, it can be, if you use Docker exclusively for every project. even then, it is sacrifle icing flexibility for Docker lock-in. if you ever decide to not use Docker for any project, past, present, or future, then you'll have more moving parts. if you had used Vagrant, you have that one moving part that supports the rest ).
    • "Docker starts very fast". When docker is used to start a container, it starts faster than other virtual machines. However, from the perspective of productization, all vagrant hosts are started once and then stopped. For rapid deployment of the development environment, docker is a very good feature.

Therefore, we can now know that vagrant and docker are quite different. It is incorrect to directly compare them. For the development environment, vagrant is a more abstract and common solution. Docker provides only one of the special scenarios supported by vagrant.

In some extreme cases, docker can completely replace vagrant. But in more scenarios, this is incorrect. At the same time, vagrant will not block your use of docker.

Hykes has written the following arguments for these explanations of Mitchell:

If you only want to manage virtual machines, you should use vagrant. If you want to quickly develop and deploy applications, you should use docker.

Vagrant is a tool for managing virtual machines, while docker is a tool for building and deploying applications by packaging applications into lightweight containers. The two have different applicability. A container contains the data (including lib and configuration files) that the application depends on ). It ensures that the application can be executed in a reusable environment at any time.

With this container, you can easily build your container and deploy it anytime, anywhere.

Docker can only be executed on Linux! In fact, Docker can be installed on MAC and Windows. If you install Docker on a MAC, there will be a simplified Linux VM of about 25 MB to serve as the direct communication between MAC and docker. Once Docker is installed, you can use the same command. In this way, the world is better: You can better test and develop your applications through a lightweight volume, and it is easy to distribute these applications (such as through https://index.docker.io ). You don't need to know how to manage these virtual machines. Instead, you just need to take virtual machines as a part of the process.

Theoretically, vagrant can be used as an abstract data layer for docker. The reasons are as follows:

    • First, vagrant is not a better abstraction of docker. Vagrant is designed to manage virtual machines, while docker is designed to manage applications. This means that docker was designed to combine applications in multiple ways. In docker, processes, log streams, environment variables, and network links between components are the underlying prototype. In vagrant, machines, block devices, and ssh keys are the bottom-layer prototype. Vagrant works at the bottom of the system. It interacts with another vagrant container only by treating it as a machine that can "boot" and "log. Therefore, you can install the plug-in on docker, execute the "vagrant up" command, and wait for good things to happen.
    • The lock-in argument ). "" If you use Vagrant as an alias action, you will not be locked into Docker! "From the vagrant perspective of Virtual Machine Management, there is no error in this sentence: Docker is not another independent container. Like EC2 and VMware, we need to avoid creating something bundled with other tools. Docker has no requirements on the host machine. It allows you to deploy the host machine anywhere through lightweight containers. When deploying an application, you do not need to consider the environment in which the Department should be deployed. For example, you can deploy applications on hosts provided by others (EC2 or vagrant may have been deployed.

Finally, we can say that Vagrant is suitable for managing virtual machines, while docker is suitable for managing application environments.

Install Docker in CentOS 6/7 Series

Detailed explanation of the entire process of building Gitlab CI for Docker

Docker installation application (CentOS 6.5_x64)

What is the difference between Docker and a normal Virtual Machine?

Use MySQL in Docker

Docker will change everything

Docker installation application (CentOS 6.5_x64)

Docker details: click here
Docker: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.