docker swarm
[root@localhost ~]# docker swarm init --advertise-addr 192.168.0.107
Swarm initialized: current node (hfpe6zgjrjb5afzabannec3ko) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-4sj07p6oikjom64rkcu3expmaelzsyfyjninbrc53wqo6cnrxy-as7q387yy4akr1j6xwuw5mt98 192.168.0.107:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
[root@localhost ~]#
[root@localhost ~]# firewall-cmd --permanent --add-port={2376,2377,7946}/tcp
success
[root@localhost ~]# firewall-cmd --permanent --add-port={7946,4789}/udp
success
[root@localhost ~]# firewall-cmd --reload
success
docker service create --name web1 -p 80:80 --replicas 5 nginx
vus0grc7koogpwipbmzga94k6
overall progress: 5 out of 5 tasks
1/5: running
2/5: running
3/5: running
4/5: running
5/5: running
verify: Service converged
[root@localhost ~]#
Swarm initialized: current node (hfpe6zgjrjb5afzabannec3ko) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-4sj07p6oikjom64rkcu3expmaelzsyfyjninbrc53wqo6cnrxy-as7q387yy4akr1j6xwuw5mt98 192.168.0.107:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
[root@localhost ~]#
[root@localhost ~]# firewall-cmd --permanent --add-port={2376,2377,7946}/tcp
success
[root@localhost ~]# firewall-cmd --permanent --add-port={7946,4789}/udp
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
hfpe6zgjrjb5afzabannec3ko * localhost.localdomain Ready Active Leader 19.03.4
u3mfvjrjbohs8rxjw7vwjt5x4 localhost.localdomain Ready Active Reachable 19.03.4
[root@localhost ~]#
root@localhost ~]# docker info
Client:
Debug Mode: false
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 19.03.4
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: hfpe6zgjrjb5afzabannec3ko
Is Manager: true
ClusterID: v9ffk5xnxrbm2ivexs1fgs6ag
Managers: 2
Nodes: 2
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.0.107
Manager Addresses:
192.168.0.107:2377
192.168.0.109:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: BCJU:QRFU:FUUO:63F3:6UEZ:RZFA:QPFZ:2K6Y:GMZF:WICS:AP2E:6VKN
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: bridge-nf-call-ip6tables is disabled
WARNING: Running Swarm in a two-manager configuration. This configuration provides
no fault tolerance, and poses a high risk to lose control over the cluster.
Refer to https://docs.docker.com/engine/swarm/admin_guide/ to configure the
Swarm for fault-tolerance.
[root@localhost ~]#
node 1
[root@localhost ~]# docker swarm join --token SWMTKN-1-4sj07p6oikjom64rkcu3expmaelzsyfyjninbrc53wqo6cnrxy-cbraqf14rlfoe9q7bniswv3mx 192.168.0.107:2377
This node joined a swarm as a manager.
[root@localhost ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
hfpe6zgjrjb5afzabannec3ko localhost.localdomain Ready Active Leader 19.03.4
u3mfvjrjbohs8rxjw7vwjt5x4 * localhost.localdomain Ready Active Reachable 19.03.4
[root@localhost ~]#
[root@localhost ~]# docker info
Client:
Debug Mode: false
Server:
Containers: 48
Running: 14
Paused: 0
Stopped: 34
Images: 10
Server Version: 19.03.4
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: u3mfvjrjbohs8rxjw7vwjt5x4
Is Manager: true
ClusterID: v9ffk5xnxrbm2ivexs1fgs6ag
Managers: 2
Nodes: 2
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.0.109
Manager Addresses:
192.168.0.107:2377
192.168.0.109:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: RTYH:Y3O4:JL3E:SRDS:B2SW:PT2H:QNUP:DQ7X:K3YI:3DGC:QKAX:JQQX
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: Running Swarm in a two-manager configuration. This configuration provides
no fault tolerance, and poses a high risk to lose control over the cluster.
Refer to https://docs.docker.com/engine/swarm/admin_guide/ to configure the
Swarm for fault-tolerance.
[root@localhost ~]#
Client:
Debug Mode: false
Server:
Containers: 48
Running: 14
Paused: 0
Stopped: 34
Images: 10
Server Version: 19.03.4
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: u3mfvjrjbohs8rxjw7vwjt5x4
Is Manager: true
ClusterID: v9ffk5xnxrbm2ivexs1fgs6ag
Managers: 2
Nodes: 2
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.0.109
Manager Addresses:
192.168.0.107:2377
192.168.0.109:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: RTYH:Y3O4:JL3E:SRDS:B2SW:PT2H:QNUP:DQ7X:K3YI:3DGC:QKAX:JQQX
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: Running Swarm in a two-manager configuration. This configuration provides
no fault tolerance, and poses a high risk to lose control over the cluster.
Refer to https://docs.docker.com/engine/swarm/admin_guide/ to configure the
Swarm for fault-tolerance.
[root@localhost ~]#
node
[root@localhost ~]# docker swarm leave --force
Node left the swarm.
[root@localhost ~]# docker swarm init
Swarm initialized: current node (wh6kz1ydst4szfo836d7ov9ey) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-0vbqjd87gsmax3sroitj6dbll4phmephzdoxo4o7sxikhfoe1r-59nt9xftv5chyhyz9728grzt9 192.168.0.107:2377
[root@localhost ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
wh6kz1ydst4szfo836d7ov9ey * localhost.localdomain Ready Active Leader 19.03.4
[root@localhost ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
u0gze6eklats9p49gv2pbb9xq localhost.localdomain Ready Active 19.03.4
wh6kz1ydst4szfo836d7ov9ey * localhost.localdomain Ready Active Leader 19.03.4
root@localhost ~]# docker info
Client:
Debug Mode: false
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 19.03.4
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: wh6kz1ydst4szfo836d7ov9ey
Is Manager: true
ClusterID: dj9bcmp0f1khxbsedfrrv0i02
Managers: 1
Nodes: 2
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.0.107
Manager Addresses:
192.168.0.107:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: BCJU:QRFU:FUUO:63F3:6UEZ:RZFA:QPFZ:2K6Y:GMZF:WICS:AP2E:6VKN
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: bridge-nf-call-ip6tables is disabled
[root@localhost ~]#
node 1
[root@localhost ~]# docker swarm join --token SWMTKN-1-0vbqjd87gsmax3sroitj6dbll4phmephzdoxo4o7sxikhfoe1r-59nt9xftv5chyhyz9728grzt9 192.168.0.107:2377
This node joined a swarm as a worker.
[root@localhost ~]# docker info
Client:
Debug Mode: false
Server:
Containers: 48
Running: 14
Paused: 0
Stopped: 34
Images: 10
Server Version: 19.03.4
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: u0gze6eklats9p49gv2pbb9xq
Is Manager: false
Node Address: 192.168.0.109
Manager Addresses:
192.168.0.107:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.779GiB
Name: localhost.localdomain
ID: RTYH:Y3O4:JL3E:SRDS:B2SW:PT2H:QNUP:DQ7X:K3YI:3DGC:QKAX:JQQX
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
docker service create --name web1 -p 80:80 --replicas 5 nginx
vus0grc7koogpwipbmzga94k6
overall progress: 5 out of 5 tasks
1/5: running
2/5: running
3/5: running
4/5: running
5/5: running
verify: Service converged
[root@localhost ~]#
root@localhost ~]# docker service ps web1
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
u06x4zty0764 web1.1 nginx:latest localhost.localdomain Running Running 12 minutes ago
ucnhsmezofcn web1.2 nginx:latest localhost.localdomain Running Running 12 minutes ago
qnovepvdliob web1.3 nginx:latest localhost.localdomain Running Running 12 minutes ago
euicwuveru07 web1.4 nginx:latest localhost.localdomain Running Running 12 minutes ago
dx18pw6p39j2 web1.5 nginx:latest localhost.localdomain Running Running 12 minutes ago
[root@localhost ~]#
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
u06x4zty0764 web1.1 nginx:latest localhost.localdomain Running Running 12 minutes ago
ucnhsmezofcn web1.2 nginx:latest localhost.localdomain Running Running 12 minutes ago
qnovepvdliob web1.3 nginx:latest localhost.localdomain Running Running 12 minutes ago
euicwuveru07 web1.4 nginx:latest localhost.localdomain Running Running 12 minutes ago
dx18pw6p39j2 web1.5 nginx:latest localhost.localdomain Running Running 12 minutes ago
[root@localhost ~]#
Comments
Post a Comment