Docker 简介


Docker 为应用程序提供了独立的运行环境,使得在应用程序在构建,测试以及部署时运行在相同的环境下,更加可移植。简单来说 Docker 提供应用程序容器,使得应用程序具备运行所需环境,可以基于一个内核为不同的应用程序配置不同的库和环境,容器保证了运行环境的独立,使得应用程序相互之间不会影响到对方。总之,Docker 可以看成为应用程序提供独立运行环境的容器

Docker Workflow

  1. 将应用程序代码以及依赖放入 Docker 容器

    • 创建 Dockerfile,用来指定运行环境以及拉取应用程序代码
    • 如果应用程序依赖外部服务,比如:MySQL,Redis 等,需要在 Docker Compose file中引用它们的镜像
    • 通过 Docker Machine 启动虚拟机来运行容器
  2. 配置网络以及存储

  3. 上传到 registry 跟团队合作

  4. 使用 Universal Control Plane 工具来管理多主机集群

  5. 使用 Docker Cloud 将应用程序部署到云上,或使用 Docker Datacenter 部署到自己的物理主机上

Windows 上安装

在 Windows 上可以通过两种方式安装 Docker:

第一种安装方案,Docker 是运行在 windows 本地的应用程序,至少需要 64 位的 windows10,以及微软的Hyper-V 开启

第二种安装方案,Docker 不是 windows 本地的应用程序,而是通过 docker-machine 来创建 Linux 虚拟机以运行 Docker

Docker Toolbox includes the following Docker tools:

  • Docker CLI client for running Docker Engine to create images and containers
  • Docker Machine so you can run Docker Engine commands from Windows terminals
  • Docker Compose for running the docker-compose command
  • Kitematic, the Docker GUI
  • the Docker QuickStart shell preconfigured for a Docker command-line environment
  • Oracle VM VirtualBox

To run Docker, your machine must have a 64-bit operating system running Windows 7 or higher. Additionally, you must make sure that virtualization is enabled on your machine(use Speccy to check it).

Because the Docker Engine daemon uses Linux-specific kernel features, you can’t run Docker Engine natively on Windows. Instead, you must use the Docker Machine command, docker-machine, to create and attach to a small Linux VM on your machine. This VM hosts Docker Engine for you on your Windows system.

Tip: One of the advantages of the newer Docker for Windows solution is that it uses native virtualization and does not require VirtualBox to run Docker.

The installer adds Docker Toolbox, VirtualBox, and Kitematic to your Applications folder. On your Desktop, find the Docker QuickStart Terminal icon to launch a pre-configured Docker Toolbox terminal. Type the docker run hello-world command and press RETURN to test if you have already installed Docker successfully.


Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. The use of Linux containers to deploy applications is called containerization. Containers are not new, but their use for easily deploying applications is.


A container is launched by running an image. An image is an executable package that includes everything needed to run an application–the code, a runtime, libraries, environment variables, and configuration files.

A container is a runtime instance of an image–what the image becomes in memory when executed (that is, an image with state, or a user process). You can see a list of your running containers with the command, docker ps, just as you would in Linux.

容器 VS. 虚拟机

A container runs natively on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight.

By contrast, a virtual machine (VM) runs a full-blown “guest” operating system with virtual access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need.

Xiao Wenbin
Xiao Wenbin
Natural Language Processing Engineer

My research interests include machine learning, information retrieval and natural language processing.