编程知识 cdmana.com

Introduction and installation of docker (CentOS in Linux Environment)

Docker Is an open source application container engine , be based on Go Language and compliance Apache2.0 Open source agreement . Docker Allows developers to package their applications and dependencies into a lightweight package 、 In a portable container , Then post to any popular Linux On the machine , You can also implement virtualization . Containers are completely sandboxed using the sandbox mechanism , There will be no interface between them ( Be similar to app), More importantly, the container performance overhead is minimal .

1. Docker Problem solved

  • Solve the running environment and configuration problems , Easy to publish , Convenient for continuous integration .
    • Because different machines have different operating systems , And different libraries and components , A large number of environment configuration operations are needed to deploy an application to multiple machines .
    • Docker It mainly solves the problem of environment configuration , It's a virtualization technology , Isolate processes , Isolated processes are independent of the host operating system and other isolated processes .
    • Use Docker You can leave the application code untouched , There is no need for developers to learn technology in a specific environment , You can deploy existing applications on other machines .
  • Use Docker The benefits of :
    • Easy to deploy and secure , Good isolation , Fast rollback , The cost is low
  • Docker Application scenarios of :
    • Web Automated packaging and distribution of applications .
    • Automated testing and continuous integration 、 Release .
    • Deploy and tune databases or other backend applications in a service-oriented environment .

2. Docker framework

Docker Using client - The server (C/S) Architecture mode , Using a remote API To manage and create Docker Containers . Docker Container by Docker Mirror image (Images) To create , The relationship between containers and mirrors is similar to that between objects and classes in object-oriented programming .

  • Docker Mirror image (Images)
    • Used to create Docker Containers (Container) The template of .
  • Docker Containers (Container)
    • An application or group of applications running independently .
  • Docker client (Client)
    • Use it from the command line or other tools Docker API And Docker Of the daemons .
  • Docker host (Host)
    • A physical or virtual machine is used to execute Docker Daemons and containers .
  • Docker Warehouse (Registry)
    • Used to save images (Images), It can be understood as a code repository in code control ,Docker Hub Provides a large set of mirrors for use .
  • Docker Machine
    • A simplification Docker Command line tools installed , It can be installed on the corresponding platform through a simple command line Docker.

3. CentOS Lower installation Docker

requirement CentOS 6.5 Or later , The system is required to be 64 position 、 The kernel version of the system is 2.6.32-431 Or higher . The environment is demonstrated here CentOS 8.2.

  • add to Docker The repository
    • First , You must add an external repository to get Docker CE. The official Docker CE CentOS The repository .
  1. download docker-ce Of repo
[root@localhost jenkins]# curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1919  100  1919    0     0   3408      0 --:--:-- --:--:-- --:--:--  3402
  1. Installation dependency
[root@localhost jenkins]# yum install https://download.docker.com/linux/fedora/32/x86_64/stable/Packages/containerd.io-1.3.7-3.1.fc32.x86_64.rpm
  1. install docker-ce
[root@localhost jenkins]# yum install docker-ce
  1. start-up docker
[root@localhost jenkins]# systemctl start docker
  1. Check docker Whether the service is running normally :
[root@localhost jenkins]# systemctl status docker
  1. test run hello-world
    • Because there is no hello-world This mirror image , So I'll download one hello-world Mirror image , And run it in a container .
[root@localhost jenkins]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:8c5aeeb6a5f3ba4883347d3747a7249f491766ca1caa47e5da5dfcf6b9b717c0
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

版权声明
本文为[Super_ Charles]所创,转载请带上原文链接,感谢

Scroll to Top