-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_swarm.txt
70 lines (65 loc) · 2.65 KB
/
docker_swarm.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#To start docker swarm and listen on all the interfaces of the machine
docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
# To initialise a swarm
docker swarm init --advertise-addr 192.168.99.121
# To Join the swarm as manager
# Join swarm as node
docker swarm join \
--token SWMTKN-1-3tv9ndtw9l9m5zhtrm2vp50b9597i3z6huhkam5cie4es0y353-6ir6bb0ht985c1dqoa1bvfggz \
192.168.1.102:2377
# List nodes in the swarm
docker node list
# To drain manager so that tasks are not assigned to it
docker node update --availability drain manager0
root@Manager0:~# docker node list
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
2of7g9psv8u2jls6jjwpa3dqo * Manager0 Ready Active Leader
5fv4xd7zk191rp8mciwshym0l Node1 Ready Active
6iwa81l5ss5gaupxwrz9i6f3c Node0 Ready Active
root@Manager0:~# docker node update --availability drain Manager0
Manager0
root@Manager0:~# docker node list
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
2of7g9psv8u2jls6jjwpa3dqo * Manager0 Ready Drain Leader
5fv4xd7zk191rp8mciwshym0l Node1 Ready Active
6iwa81l5ss5gaupxwrz9i6f3c Node0 Ready Active
# Listing services in docker swarm
docker service ls
# Create service in docker swarm
Error: image library/service:latest not found
root@Manager0:~# docker service create --name du centos du
f2xwvptlqhabodnjn4j4t0fj4
root@Manager0:~#
root@Manager0:~#
root@Manager0:~# docker service ls
ID NAME REPLICAS IMAGE COMMAND
f2xwvptlqhab du 0/1 centos du
# Scale up services
docker service scale helloworld=5
# Running a webservice in docker swarm
docker service create --replicas 2 --name www-service --publish 80:80/tcp www_server
#Autoscaling test
270 docker build -t hello-service .
271 docker images
272 docker run hello-service:latest
274 docker images
280 docker build -t hello-service .
281 docker service
282 docker service scale
283 docker service scale hello-service=10
288 docker service update
289 docker ps
290 docker service update
291 docker service update --help
292 docker service update --image hello-service:latest hello-service
293 docker ps
297 docker build -t hello-service:v1.2 .
298 docker service update --image hello-service:v1.2 hello-service
299 docker service ps
300 docker service ps hello-service
301 docker service scale hello-service=2
302 docker service ps hello-service
303 docker service ps
308 docker service ps hello-service
311 docker build -t hello-service:v1.3 .
313 docker service update --image hello-service:v1.3 hello-service