The machine I use:
- CentOS 7 (Tencent's cloud server)
table of Contents
1. What is Docker
2. Installation prerequisites
Three, installation steps
- Download Docker
- Install using the source Docker repository
- Download files to install manually
- Install Docker
- Run example
Four, additional operations
1. What is Docker
Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image, and then publish it to any popular Linux or Windows machine, which can also be virtualized. Containers use the sandbox mechanism completely, and there will be no interfaces between them.
Docker image is here
Advantages :
- Docker saves us a lot of production environment testing, because the development environment is your production environment
- Docker can better utilize (ya) and (zha) computer performance
2. Installation prerequisites
- If you have installed an old version of Docker, please uninstall it first, please read step 2 of the additional steps
- You need a computer (or server) with Windows/macOS/Linux
- Have a stable internet connection
- Read this article carefully and patiently hhh
Three, installation steps
-
Download Docker
a. Use Docker's warehouseInstall dependencies
sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
To add a warehouse (stable version) and
wish to use other versions, please refer to this part of the command in the official Docker documentation !
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
Should see
repo saved to /etc/yum.repos.d/docker-ce.repo
b. Download the file and install it manually
(Dig the hole first, fill it in when you have time)
-
Install Docker
sudo yum install docker-ce docker-ce-cli containerd.io
Show Compelete! to go to the next step
Tips: If GPG key verification appears, please check if the key matches the following string060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
-
Start Docker
sudo systemctl start docker ps -ef | grep docker
As long as dockerd appears, it proves that docker started successfully
root 30820 1 0 14:10 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 31127 23503 0 14:11 pts/0 00:00:00 grep --color=auto docker
-
Run the Hello World example
[root@VM_0_15_centos ~]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:d1668a9a1f5b42ed3f46b70b9cb7c88fd8bdc8a2d73509bb0041cf436018fbf5 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/
Then it proves that Docker has been installed and can be used normally
Four, optional operations
-
Docker change source
cd /etc/docker vim daemon.json
Add the following content to the daemon.json file
{ "registry-mirrors": [ "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn", "https://registry.docker-cn.com", "https://docker.mirrors.ustc.edu.cn" ], "dns": ["223.5.5.5","223.6.6.6"] }
Then restart Docker
systemctl restart docker.service
-
Uninstall the old version of Docker
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
After completing this step, yum will report that all the above packages have not been installed,
and the images, containers, sub-volumes and network configuration under /var/lib/docker/ will be preserved
Part of the article is my own view of Docker, which does not mean that it is absolutely correct.