CentOs 7.6 安装docker
https://docs.docker.com/engine/install/centos/
Uninstall old versions
```
$ sudo yum remove docker\
docker-client \docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
```
Install using the repository
```
$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
--add-repo \
```
https://download.docker.com/linux/centos/docker-ce.repo
INSTALL DOCKER ENGINE
$ sudo yum install docker-ce docker-ce-cli containerd.io
$ docker swarm init --force-new-cluster --advertise-addr 192.168.1.79:2377 --唯一方法是使用—force-newcluster管理节点的操作,这将去除本机之外的所有管理器身份。
设置swarm缓存数
$ sudo docker swarm update --task-history-limit 3 #(default 5)
Docker is installed but not started. The docker group is created, but no users are added to the group.
Start Docker.
$ sudo systemctl start docker
If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with something like:
$ sudo usermod-aGdocker your-user
Uninstall Docker Engine
1. Uninstall the Docker Engine, CLI, and Containerd packages:
$ sudo yum remove docker-ce docker-ce-cli containerd.io
2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
$ sudo rm-rf/var/lib/docker
swarm设置
docker swarm join-token worker查看工作节点的 token在集群的leader服务器上生成token
$ docker swarm join --token SWMTKN-1-32nwe7y5wjgfsk8xc68k0m0cu1x0nypjj9bv8v8uvsah49jh8z-3up5uu2lqv4ys10ub2ww14ie9 10.5.30.11:2377加入集群中 在从属的服务器上运行命令
$ docker node ls --查看所有集群节点
$ docker node update --availability active | pause hostname --更新指定主机名的节点状态
$ docker node promote 工作节点主机名1 将一个或多个节点推入到群集管理器中
$ docker node demote从群集(swarm)管理器中降级一个或多个节点
$ docker node rm hostname|id 从Nodes列表移除指定node 删除某个节点(-f强制删除)
This node joined a swarm as a worker. 看到返回结果,表示成功