Docker use record (a)

What is a docker?

Docker is an open source project, was born in early 2013, it was initially an amateur project internal dotCloud company. It is based on Google's launch of the Go language. Project later joined the Linux Foundation to comply with the Apache2.0 agreement, the project code is maintained on GitHub

Docker belongs Linux package container, the container provides an easy to use interface. It is the most popular Linux container solutions.
Docker application and dependence of the program, which is packaged in a file. This file is run, it will generate a virtual container. Running in the virtual container, just like running on a real physical machine. With Docker, do not worry about environmental issues.

Overall, Docker fairly simple interface, users can easily create and use a container, put their applications into the container. The container may also be version management, copying, sharing, modifying, just like ordinary management of the same Code

Why use docker

As a new approach to virtualization Docker has many advantages compared to the traditional approach to virtualization.
First, start Docker container can be achieved in the second stage, this virtual machine compared to the traditional way is much faster. Secondly, Docker high utilization of system resources, can run thousands of Docker containers on a host computer at the same time.
In addition to running application container which substantially does not consume additional system resources, such high performance applications, while the overhead of the system as small as possible. Traditional virtual machines run 10 different applications will play 10 virtual machines, while Docker only need to start the application to 10 isolated.
Specifically, Docker has a large advantage in the following aspects

  • Faster delivery and deployment
    - the development and operation and maintenance (devop) personnel, the most hope is to create one or configurations can be shipped anywhere normal
    to build a set of development container Developers can use a standard image, development Upon completion, operation and maintenance personnel can directly use this container to deploy code. Docker can quickly create a container, fast iterative application, and visible throughout the entire process, so that other members of the team easier to understand how the application is to create and work. Docker containers very light soon! Start time is the second level of the container, a large amount of reducing development, testing, deployment time
  • Higher virtualization
    • Run Docker containers do not require additional hypervisor support, it is kernel-level virtualization, it is possible to achieve higher performance and efficiency
  • Easier migration and expansion
    • Docker containers can run on almost any platform, including physical machines, virtual machines, public cloud, private cloud, PCs, servers and so on. This compatibility allows users to migrate an application from one platform to another directly.
  • Simpler management
    • Use Docker, only small changes, you can replace a lot of conventional updating. All modifications are distributed and updated incrementally, enabling automated and efficient management
  • Simpler management
    • Use Docker, only small changes, you can replace a lot of conventional updating. All modifications are distributed and updated incrementally, enabling automated and efficient management
  • Comparison with the virtual machine
    properties | container | virtual machine
    ------- | ------ | --------
    Start | second grade | minute class
    hard drive | usually MB | generally GB
    performance | near native | weaker than the
    system of support | standalone supports thousands of containers | general dozens

Above removal from entry to practice docker

The three concepts docker

  • 1. Mirror (image): similar to the virtual machine image, is a read-only file system that contains the template for Docker engine. Any application needs to run the environment, while the mirror is used to provide this operating environment. For example, a mirror is a template Ubuntu Ubuntu operating system environment contains, in the same way on the mirror coat Apache software, it can be called Apache Mirror
  • 2. A container (Container): similar to a lightweight sandbox, it can be seen as a minimalist Linux environment (including root access, process space, user space and cyberspace, etc.), as well as running them application. Docker container to run using the engine, to isolate the various applications. Container is image creation application instance, you can create, start, stop, delete container, between the individual containers are isolated from each other, independently of each other. Note: The image itself is read-only, when a container from a mirrored boot, Docker create a writable layer in the upper mirror, the mirror itself is unchanged
  • 3. Warehouse (Repository): similar to the code repository, here is a mirror warehouse is a centralized repository for image files Docker place. Note the difference between the registration server (Registry): the local registration server is stored in a warehouse, typically have a plurality of warehouses; and warehouse storage areas is mirrored, generally mirror each warehouse storage for a class, the use of tag to distinguish each mirror, For example, there are multiple versions of Ubuntu warehouse storage (12.04,14.04, etc.) of Ubuntu mirror

docker three purposes

  • One-off environment. For example, local people's software testing, continuous integration when providing unit test and build environment
  • Provide flexible cloud services. Because Docker can open with the container closed, it is suitable for dynamic expansion and volume reduction
  • The formation of micro-services architecture. By a plurality of containers, the machine can run a plurality of services, the machine can be simulated in the micro-service architecture

docker installation

Docker is an open source commercial product, available in two versions: Community Edition (Community Edition, abbreviated as CE) and Enterprise Edition (Enterprise Edition, abbreviated as EE). Enterprise Edition includes a number of fee-based services, individual developers generally use less. The following are introduced for Community Edition

  • Centos series
    • Centos6, may be used to install the library EPEL Docker, the following command
sudo yum install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
sudo yum install docker-io
- Centos7,CentOS-Extras库中已带Docker,可以直接安装
`sudo yum install docker`
- 安装之后启动Docker服务,并让它随系统启动自动加载
`sudo service docker start`或`systemctl start docker`
`sudo chconfig docker on`
  • Ubuntu Series
    • Previous versions of Ubuntu 14.04
sudo apt-get update
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo reboot  # 重启
- Ubuntu14.04以上版本
sudo apt-get update
sudo apt-get install docker-ce
service docker start 或者 systemctl start docker

tip: very slow at downloading Ubuntu case a replacement source software, improve download speed

  • After installing Docker, due to the direct access dockerhub download mirrors will be very slow, the proposed replacement of domestic mirroring can be done by modifying the file /etc/docker/daemon.js
{
    "registry-mirrors": [
        "http://hub-mirror.c.163.com",
        "https://registry.docker-cn.com"
    ]
}

If you are using the cloud server (such as: Ali cloud), cloud server provider will usually provide a default mirror server does not need to be specified manually

Reproduced in: https: //www.jianshu.com/p/7b0e9aff81e4

Guess you like

Origin blog.csdn.net/weixin_34252686/article/details/91182302