docker swarm集群安装使用
1、安装master
docker swarm init --advertise-addr 10.98.10.186 Swarm initialized: current node (qemrm3oqc537jpcsp0vqb60s6) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-3j15bhg901hjyrqpdnrdmgk9k6thpnltq9y3d8c10m7hr4dags-a3kdkgzhdln7n5ofs4udfzwx9 10.98.10.186:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
2、添加work node
docker swarm join --token SWMTKN-1-3j15bhg901hjyrqpdnrdmgk9k6thpnltq9y3d8c10m7hr4dags-a3kdkgzhdln7n5ofs4udfzwx9 10.98.10.186:2377
3、启动服务、查看服务
#部署服务 docker service create --replicas 1 --network nginx_net --name my_nginx -p 80:80 -d nginx # 就创建了一个具有一个副本(--replicas 1 )的nginx服务,使用镜像nginx #查看服务 [root@localhost ~]# docker service ls
4、部署portainer 管理docker swarm
[root@manager swar]# more docker-compose.yml version: '3.2' services: agent: image: portainer/agent:latest volumes: - /var/run/docker.sock:/var/run/docker.sock - /var/lib/docker/volumes:/var/lib/docker/volumes networks: - agent_network deploy: mode: global placement: constraints: [node.platform.os == linux] portainer: image: portainer/portainer-ce:2.16.2 command: -H tcp://tasks.agent:9001 --tlsskipverify ports: - "9443:9443" - "9000:9000" - "8000:8000" volumes: - portainer_data:/data networks: - agent_network deploy: mode: replicated replicas: 1 placement: constraints: [node.role == manager] networks: agent_network: driver: overlay attachable: true volumes: portainer_data:
5、启动服务
#docker stack deploy -c docker-compose.yml portainer Creating network portainer_agent_network Creating service portainer_agent Creating service portainer_portainer
6、部署、运行成功之后,我们可以通过下面的地址来访问portainer-ce的管理页面。
https://10.98.10.186:9443/
首次登录,需要在登录页面输入一个不少于12位的密码,以创建登录用户。在主页面我们可以看到系统的一个概况。
做一个决定,并不难,难的是付诸行动,并且坚持到底。