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 .
DockerIt 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 .
DockerYou 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 .
DockerThe benefits of ：
- Easy to deploy and secure , Good isolation , Fast rollback , The cost is low
DockerApplication 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 .
- 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
- 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
- install docker-ce
[root@localhost jenkins]# yum install docker-ce
- start-up docker
[root@localhost jenkins]# systemctl start docker
- Check docker Whether the service is running normally ：
[root@localhost jenkins]# systemctl status docker
- 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 .
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: The Docker client contacted the Docker daemon. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 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/