Docker application container engine introduction and construction

attach:

Meow's blog: w-blog.cn

Official Git address: https://github.com/moby/moby

1. Why Docker is hot

  • Up to now, Docker has 48570 stars on github
  • Alibaba Cloud, Tencent Cloud, AWS, have launched their own Docker platform
  • 70% of surveyed enterprises are already using or considering using Docker;

Looking back, the software systems (such as Hadoop) that managers tended to be popular in the past all solved the pain points in a field, and Docker is no exception. The author concluded that the following pain points were solved by Docker:

  • Building a complex environment Before the author installs a software, there may be various dependencies that are extremely complex (for example: APPRTC), Docker can package the environment dependencies together and can use it out of the box with only one command
  • Isolation - Each user instance is isolated from each other and does not affect each other. For example, your program A needs to use PHP 7.0, and program B needs to use PHP 7.2, but program A cannot use PHP 7.2. You can only choose to open two when virtualized. Using docker, you can use docker to communicate with each other on the same server. Smooth operation without impact
  • Quota/Measurable - Each user instance can provide its computing resources on demand, and the resources used can be metered. The author had an accident in the operating environment. Generally speaking, except for some problems in application A, the CPU was high, and all other programs could not be accessed. Some dockers can allocate resources at a fixed rate. Unimportant programs will not affect important programs.
  • Mobility - User instances can be easily copied, moved and rebuilt, and rolled back.
  • Basically no additional performance consumption is added. Docker is directly transplanted on the Linux kernel, and the underlying device is virtually isolated by running the Linux process, so that the system performance loss is much lower than that of the virtual machine, which is almost negligible. At the same time, the start and stop of Docker application containers is very efficient, which can support the horizontal expansion of large-scale distributed systems, which really brings good news to enterprise development.
  • DevOps continuously iteratively delivers Docker technology to package and deliver applications in containers, so that applications can be shared among different teams, and applications can be deployed in any environment by mirroring. This avoids the problem of collaboration between teams and becomes an important tool for enterprises to achieve DevOps goals. The Docker technology delivered in the form of containers supports continuous development and iteration, which greatly improves the speed of product development and delivery.

As Liu Yankai, chief expert of cloud computing integration cloud technology at China HP said: "The development of any technology and its popularity are because it can solve the problems that plague people", Docker is used to solve this problem

2. Build and install

Here choose to use Centos to install Docker

  1. Install the required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
> yum install -y yum-utils device-mapper-persistent-data lvm2
  1. Set up the release repository with the following command. Even if you want to install builds from edge and test repositories, release repositories are always required.
> yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  1. Optional: enable edge and test repositories. These repositories are included in the docker.repo file above, but are disabled by default. You can enable them with stable repositories
> yum-config-manager --enable docker-ce-edge
> yum-config-manager --enable docker-ce-test

You can disable edge and test repositories by running the command with that flag.

> yum-config-manager --disable docker-ce-edge

Install Docker CE

The latest version of Docker-ce can be installed directly by the following command

> yum install docker-ce

If multiple Yum repositories are enabled, installing or updating without specifying a version yum install or yum update commands will always install the highest possible version, which may not suit your stability needs.

On production systems, you should install a specific version of Docker CE instead of always using the latest version. List available versions.

This example uses the sort -r command to sort the results by version number, highest to lowest.

> yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64            18.02.0.ce-1.el7.centos             docker-ce-edge  
docker-ce.x86_64            18.01.0.ce-1.el7.centos             docker-ce-edge  
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-edge  
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-edge  
docker-ce.x86_64            17.11.0.ce-1.el7.centos             docker-ce-edge  
docker-ce.x86_64            17.10.0.ce-1.el7.centos             docker-ce-edge  

The content of the list depends on which repositories are enabled and is specific to your CentOS .el7 version (in this example, indicated by the version suffix). Choose a specific version to install. The second column is the version string. You can use the entire version string. The third column is the repository name, which indicates which repository the package came from. To install a specific version, append the version string to the package name separated by a hyphen (-).

Note: The version string is the version of the package name plus the first hyphen. In the above example, the full package name is docker-ce-17.03.0.ce

In order to build Kubernetes later, you can refer to the description in the update log

kubernetes / CHANGELOG-1.8.md at master · kubernetes / kubernetes · GitHub

Kubernetes 1.8  <--Docker 1.11.2 to 1.13.1 and 17.03.2

Here select Rancher certified 17.03.2 and K8S supported version

# 先安装docker-ce-selinux-17.03.2.ce,否则安装docker-ce会报错
> yum install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm 
> yum install docker-ce-17.03.2.ce

Start Docker and set it to autostart on boot.

> systemctl start docker
> systemctl enable docker

docker verifies that the installation is correct by running the hello-world image.

> docker run hello-world
# 如下输出证明已经完成了Docker环境的搭建
Hello from Docker!

3 Summary

The first step has been completed and the Docker environment can be used. In the next step, we need to be familiar with some commands related to Docker.

Note: The author has limited ability and I hope that everyone can point out the wrong places, and I hope to communicate more!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325378638&siteId=291194637