1, Install docker
system information
[root@localhost yum.repos.d]# cat /etc/centos-release CentOS Linux release 7.8.2003 (Core) [root@localhost yum.repos.d]# uname -a Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@localhost yum.repos.d]#
1. Install yum extension tool
Yum install - y Yum utils ා (the role of Yum utils is to manage repository and extension package tools, and add repo files)
2. Add docker source
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo [root@localhost yum.repos.d]# ls -l //Total consumption 40 -rw-r--r--. 1 root root 1664 4 August 06:01 CentOS-Base.repo -rw-r--r--. 1 root root 1309 4 August 06:01 CentOS-CR.repo -rw-r--r--. 1 root root 649 4 August 06:01 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 4 August 06:01 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 4 August 06:01 CentOS-Media.repo -rw-r--r--. 1 root root 1331 4 August 06:01 CentOS-Sources.repo -rw-r--r--. 1 root root 7577 4 August 06:01 CentOS-Vault.repo -rw-r--r--. 1 root root 616 4 August 06:01 CentOS-x86_64-kernel.repo -rw-r--r--. 1 root root 2424 10 19 / 19 / 2019 docker-ce.repo #One more file [root@localhost yum.repos.d]#
3. Install docker CE
yum install docker-ce docker-ce-cli containerd.io
Yum list docker CE -- showduplicates | sort - R ා view the version that can be installed
yum install docker-ce-<VERSION_ STRING> docker-ce-cli-<VERSION_ STRING> containerd.i #Install the specified version
4. Start docker
systemctl start docker
5. Verify docker
Docker run Hello world output a
[root@localhost yum.repos.d]# ps -ef |grep docker root 28579 2176 0 19:01 pts/0 00:00:00 grep --color=auto docker [root@localhost yum.repos.d]# systemctl start docker [root@localhost yum.repos.d]# ps -ef |grep docker root 28589 1 2 19:01 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 28713 2176 0 19:01 pts/0 00:00:00 grep --color=auto docker [root@localhost yum.repos.d]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Pull complete Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1 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/
6. Output the above content to prove the success of docker installation
2, Initialize docker's swarm cluster management tool: (Reference: https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/)
192.168.1.6 (primary node)
[root@docker03 ~]# docker swarm init --advertise-addr 192.168.1.6 Swarm initialized: current node (9rkx43tvikx2ap88pf9eulqvc) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-5vcgwju55lnbz91wyg58payafh60xyhj8xvw5nkgzxaxwtx97m-63fxrrxedmk2hrcgy9ka4eekn 192.168.1.6:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
192.168.1.7 (cluster node) join the cluster:
docker swarm join --token SWMTKN-1-5vcgwju55lnbz91wyg58payafh60xyhj8xvw5nkgzxaxwtx97m-63fxrrxedmk2hrcgy9ka4eekn 192.168.1.6:2377
3, Install the porter (Reference: https://portainer.readthedocs.io/en/latest/deployment.html)
1. To create a volume:
docker volume create portainer_data
2. Initialize the container
docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
3. Adding a portal agent to manage swarm cluster
curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml docker stack deploy --compose-file=portainer-agent-stack.yml portaine
4. Restart docker
systemctl restart docker
5. Successful results