Why we need docker

Back in 2013, I used containers as virtual machines

Until 2021, many people are still used to using the Ubuntu or CentOS container as a virtual machine, starting the process by /bin/bash

In fact, this is not appropriate

Compared with the virtual machine, the container is actually more similar to the program installation package of windows and the rpm and dpkg installation packages of Linux, but not exactly the same

The goal of the installation package is to let users “install and run an application in the simplest way”

Usually, the installation package will copy files and set some related configurations. Some of them need to be compiled locally and then set environment variables. However, the installation has one disadvantage. If you install Python 2 and then install Python 3, it may bring some environment conflicts such as dependency libraries

In fact, docker provides the ability to install and deploy applications with one click, similar to the installation package. At the same time, it also provides environment isolation (even network isolation, etc.) similar to conda

Before docker, if you need to deploy the developed application to the user’s server, you may need to

  • Copy file
  • Set config file
  • Check the environment variables of the server
  • If the production and development environments are inconsistent, you may need to compile
  • Configure dependent Libraries
  • Install the required database

After the appearance of docker, you only need to create the corresponding container with image to obtain all environment variables and environment dependencies, which was unimaginable before, such as starting a standard MySQL service

docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql

In addition to being able to quickly publish to the production environment, this quick start advantage of docker can also be applied to many POC scenarios, fast testing of various versions, throughput, stability and compatibility testing can be implemented based on docker


Before docker appeared, there was another option to quickly distribute the development environment of dev through the virtual box based on vagrant. In fact, this practice is somewhat similar to the concept of “Infrastructure as Code”. Vagrantfile is used to define the required configuration, and the box file of the virtual box is used to distribute the local development environment

But VirtualBox is a virtual machine in essence. There is a big difference between virtual machine and docker

Send a Message