[neusoft@localhost ~/docker]$ vi /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
[neusoft@localhost ~/docker]$ docker swarm init --advertise-addr 172.24.2.63 Swarm initialized: current node (5levgh6t0qizmgwyn789dcuqx) is now a manager.
To add a worker to this swarm, run the following command:
[neusoft@localhost ~/docker]$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 5levgh6t0qizmgwyn789dcuqx * localhost.localdomain Ready Active Leader
把docker中的selinux去掉,然后重启docker
1 2 3 4 5 6 7 8 9 10 11 12
[root@localhost ~]# vi /etc/sysconfig/docker # /etc/sysconfig/docker # Modify these options if you want to change the way the docker daemon runs #OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false' OPTIONS='--log-driver=journald --signature-verification=false' if [ -z "${DOCKER_CERT_PATH}" ]; then DOCKER_CERT_PATH=/etc/docker fi
[root@localhost ~]# systemctl restart docker
将Worker节点加入swarm集群
登录到172.24.2.62主机上,执行前面创建swarm时输出的命令:
1 2 3 4
[root@localhost ~]# docker swarm join \ > --token SWMTKN-1-5g3hxk4q7eg3atnuw45ijrqei21y2aopiqha31v04jwmnz5svt-bsudrrah0zgdx7qzjcm6xvfy3 \ > 172.24.2.63:2377 This node joined a swarm as a worker.
去master查看节点信息
1 2 3 4
[neusoft@localhost ~/docker]$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 5levgh6t0qizmgwyn789dcuqx * localhost.localdomain Ready Active Leader i8x5wur7ux01rewkffavfyw3x localhost.localdomain Ready Active
[neusoft@localhost ~/docker]$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 5levgh6t0qizmgwyn789dcuqx * localhost.localdomain Ready Active Leader i8x5wur7ux01rewkffavfyw3x 172.24.2.62 Ready Active