centos7 docker安装 配置swarm集群 配置portainer管理

网友投稿 371 2022-10-28

centos7 docker安装 配置swarm集群 配置portainer管理

一、安装docker系统信息

[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、安装yum扩展工具yum install -y yum-utils #(yum-utils的作用是管理repository及扩展包的工具,添加 repo 文件)

2、添加docker源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo [root@localhost yum.repos.d]# ls -l 总用量 40 -rw-r--r--. 1 root root 1664 4月 8 06:01 CentOS-Base.repo -rw-r--r--. 1 root root 1309 4月 8 06:01 CentOS-CR.repo -rw-r--r--. 1 root root 649 4月 8 06:01 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 4月 8 06:01 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 4月 8 06:01 CentOS-Media.repo -rw-r--r--. 1 root root 1331 4月 8 06:01 CentOS-Sources.repo -rw-r--r--. 1 root root 7577 4月 8 06:01 CentOS-Vault.repo -rw-r--r--. 1 root root 616 4月 8 06:01 CentOS-x86_64-kernel.repo -rw-r--r--. 1 root root 2424 10月 19 2019 docker-ce.repo #多了一个文件 [root@localhost yum.repos.d]#

3、安装docker-ceyum install docker-ce docker-ce-cli containerd.io

yum list docker-ce --showduplicates | sort -r # 查看能安装的版本yum install docker-ce- docker-ce-cli- containerd.i #安装指定版本

4、启动dockersystemctl start docker #启动docker

5、验证dockerdocker run hello-world 输出一个

[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: ~]# 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.

三、安装portainer(参考:volume create portainer_data

2、初始化portainerdocker 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、添加portainer-agent用于管理swarm集群

curl -L -o portainer-agent-stack.yml docker stack deploy --compose-file=portainer-agent-stack.yml portaine

4、重启dockersystemctl restart docker

5、成功效果

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java实现根据模板自动生成新的PPT
下一篇:为什么纷纷舍弃Micro USB接口,选择Type-C
相关文章

 发表评论

暂时没有评论,来抢沙发吧~