@@ -14,200 +14,170 @@ Docker Swarm comes with multiple Discovery backends.
14
14
15
15
First we create a cluster.
16
16
17
- ``` bash
18
- # create a cluster
19
- $ swarm create
20
- 6856663cdefdec325839a4b7e1de38e8 # <- this is your unique <cluster_id>
21
- ```
17
+ # create a cluster
18
+ $ swarm create
19
+ 6856663cdefdec325839a4b7e1de38e8 # <- this is your unique <cluster_id>
20
+
22
21
23
22
Then we create each node and join them to the cluster.
24
23
25
- ``` bash
26
- # on each of your nodes, start the swarm agent
27
- # <node_ip> doesn't have to be public (eg. 192.168.0.X),
28
- # as long as the swarm manager can access it.
29
- $ swarm join --advertise=< node_ip:2375> token://< cluster_id>
30
- ```
24
+ # on each of your nodes, start the swarm agent
25
+ # <node_ip> doesn't have to be public (eg. 192.168.0.X),
26
+ # as long as the swarm manager can access it.
27
+ $ swarm join --advertise=<node_ip:2375> token://<cluster_id>
28
+
31
29
32
30
Finally, we start the Swarm manager. This can be on any machine or even
33
31
your laptop.
34
32
35
- ``` bash
36
- $ swarm manage -H tcp://< swarm_ip:swarm_port> token://< cluster_id>
37
- ```
33
+ $ swarm manage -H tcp://<swarm_ip:swarm_port> token://<cluster_id>
38
34
39
35
You can then use regular Docker commands to interact with your swarm.
40
36
41
- ``` bash
42
- docker -H tcp://< swarm_ip:swarm_port> info
43
- docker -H tcp://< swarm_ip:swarm_port> run ...
44
- docker -H tcp://< swarm_ip:swarm_port> ps
45
- docker -H tcp://< swarm_ip:swarm_port> logs ...
46
- ...
47
- ```
37
+ docker -H tcp://<swarm_ip:swarm_port> info
38
+ docker -H tcp://<swarm_ip:swarm_port> run ...
39
+ docker -H tcp://<swarm_ip:swarm_port> ps
40
+ docker -H tcp://<swarm_ip:swarm_port> logs ...
41
+ ...
42
+
48
43
49
44
You can also list the nodes in your cluster.
50
45
51
- ``` bash
52
- swarm list token://< cluster_id>
53
- < node_ip:2375>
54
- ```
46
+ swarm list token://<cluster_id>
47
+ <node_ip:2375>
48
+
55
49
56
50
### Using a static file describing the cluster
57
51
58
52
For each of your nodes, add a line to a file. The node IP address
59
53
doesn't need to be public as long the Swarm manager can access it.
60
54
61
- ``` bash
62
- echo < node_ip1:2375> >> /tmp/my_cluster
63
- echo < node_ip2:2375> >> /tmp/my_cluster
64
- echo < node_ip3:2375> >> /tmp/my_cluster
65
- ```
55
+ echo <node_ip1:2375> >> /tmp/my_cluster
56
+ echo <node_ip2:2375> >> /tmp/my_cluster
57
+ echo <node_ip3:2375> >> /tmp/my_cluster
58
+
66
59
67
60
Then start the Swarm manager on any machine.
68
61
69
- ``` bash
70
- swarm manage -H tcp://< swarm_ip:swarm_port> file:///tmp/my_cluster
71
- ```
62
+ swarm manage -H tcp://<swarm_ip:swarm_port> file:///tmp/my_cluster
63
+
72
64
73
65
And then use the regular Docker commands.
74
66
75
- ``` bash
76
- docker -H tcp://< swarm_ip:swarm_port> info
77
- docker -H tcp://< swarm_ip:swarm_port> run ...
78
- docker -H tcp://< swarm_ip:swarm_port> ps
79
- docker -H tcp://< swarm_ip:swarm_port> logs ...
80
- ...
81
- ```
67
+ docker -H tcp://<swarm_ip:swarm_port> info
68
+ docker -H tcp://<swarm_ip:swarm_port> run ...
69
+ docker -H tcp://<swarm_ip:swarm_port> ps
70
+ docker -H tcp://<swarm_ip:swarm_port> logs ...
71
+ ...
82
72
83
73
You can list the nodes in your cluster.
84
74
85
- ``` bash
86
- $ swarm list file:///tmp/my_cluster
87
- < node_ip1:2375>
88
- < node_ip2:2375>
89
- < node_ip3:2375>
90
- ```
75
+ $ swarm list file:///tmp/my_cluster
76
+ <node_ip1:2375>
77
+ <node_ip2:2375>
78
+ <node_ip3:2375>
79
+
91
80
92
81
### Using etcd
93
82
94
83
On each of your nodes, start the Swarm agent. The node IP address
95
84
doesn't have to be public as long as the swarm manager can access it.
96
85
97
- ``` bash
98
- swarm join --advertise=< node_ip:2375> etcd://< etcd_addr1> ,< etcd_addr2> /< optional path prefix>
99
- ```
86
+ swarm join --advertise=<node_ip:2375> etcd://<etcd_addr1>,<etcd_addr2>/<optional path prefix>
87
+
100
88
101
89
Start the manager on any machine or your laptop.
102
90
103
- ``` bash
104
- swarm manage -H tcp://< swarm_ip:swarm_port> etcd://< etcd_addr1> ,< etcd_addr2> /< optional path prefix>
105
- ```
91
+ swarm manage -H tcp://<swarm_ip:swarm_port> etcd://<etcd_addr1>,<etcd_addr2>/<optional path prefix>
92
+
106
93
107
94
And then use the regular Docker commands.
108
95
109
- ``` bash
110
- docker -H tcp://< swarm_ip:swarm_port> info
111
- docker -H tcp://< swarm_ip:swarm_port> run ...
112
- docker -H tcp://< swarm_ip:swarm_port> ps
113
- docker -H tcp://< swarm_ip:swarm_port> logs ...
114
- ...
115
- ```
96
+ docker -H tcp://<swarm_ip:swarm_port> info
97
+ docker -H tcp://<swarm_ip:swarm_port> run ...
98
+ docker -H tcp://<swarm_ip:swarm_port> ps
99
+ docker -H tcp://<swarm_ip:swarm_port> logs ...
100
+ ...
101
+
116
102
117
103
You can list the nodes in your cluster.
118
104
119
- ``` bash
120
- swarm list etcd://< etcd_addr1> ,< etcd_addr2> /< optional path prefix>
121
- < node_ip:2375>
122
- ```
105
+ swarm list etcd://<etcd_addr1>,<etcd_addr2>/<optional path prefix>
106
+ <node_ip:2375>
107
+
123
108
124
109
### Using consul
125
110
126
111
On each of your nodes, start the Swarm agent. The node IP address
127
112
doesn't need to be public as long as the Swarm manager can access it.
128
113
129
- ``` bash
130
- swarm join --advertise=< node_ip:2375> consul://< consul_addr> /< optional path prefix>
131
- ```
114
+ swarm join --advertise=<node_ip:2375> consul://<consul_addr>/<optional path prefix>
132
115
133
116
Start the manager on any machine or your laptop.
134
117
135
- ``` bash
136
- swarm manage -H tcp://< swarm_ip:swarm_port> consul://< consul_addr> /< optional path prefix>
137
- ```
118
+ swarm manage -H tcp://<swarm_ip:swarm_port> consul://<consul_addr>/<optional path prefix>
119
+
138
120
139
121
And then use the regular Docker commands.
140
122
141
- ``` bash
142
- docker -H tcp://< swarm_ip:swarm_port> info
143
- docker -H tcp://< swarm_ip:swarm_port> run ...
144
- docker -H tcp://< swarm_ip:swarm_port> ps
145
- docker -H tcp://< swarm_ip:swarm_port> logs ...
146
- ...
147
- ```
123
+ docker -H tcp://<swarm_ip:swarm_port> info
124
+ docker -H tcp://<swarm_ip:swarm_port> run ...
125
+ docker -H tcp://<swarm_ip:swarm_port> ps
126
+ docker -H tcp://<swarm_ip:swarm_port> logs ...
127
+ ...
148
128
149
129
You can list the nodes in your cluster.
150
130
151
- ``` bash
152
- swarm list consul://< consul_addr> /< optional path prefix>
153
- < node_ip:2375>
154
- ```
131
+ swarm list consul://<consul_addr>/<optional path prefix>
132
+ <node_ip:2375>
133
+
155
134
156
135
### Using zookeeper
157
136
158
137
On each of your nodes, start the Swarm agent. The node IP doesn't have
159
138
to be public as long as the swarm manager can access it.
160
139
161
- ``` bash
162
- swarm join --advertise=< node_ip:2375> zk://< zookeeper_addr1> ,< zookeeper_addr2> /< optional path prefix>
163
- ```
140
+ swarm join --advertise=<node_ip:2375> zk://<zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix>
141
+
164
142
165
143
Start the manager on any machine or your laptop.
166
144
167
- ``` bash
168
- swarm manage -H tcp://< swarm_ip:swarm_port> zk://< zookeeper_addr1> ,< zookeeper_addr2> /< optional path prefix>
169
- ```
145
+ swarm manage -H tcp://<swarm_ip:swarm_port> zk://<zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix>
170
146
171
147
You can then use the regular Docker commands.
172
148
173
- ``` bash
174
- docker -H tcp://< swarm_ip:swarm_port> info
175
- docker -H tcp://< swarm_ip:swarm_port> run ...
176
- docker -H tcp://< swarm_ip:swarm_port> ps
177
- docker -H tcp://< swarm_ip:swarm_port> logs ...
178
- ...
179
- ```
149
+
150
+ docker -H tcp://<swarm_ip:swarm_port> info
151
+ docker -H tcp://<swarm_ip:swarm_port> run ...
152
+ docker -H tcp://<swarm_ip:swarm_port> ps
153
+ docker -H tcp://<swarm_ip:swarm_port> logs ...
154
+ ...
155
+
180
156
181
157
You can list the nodes in the cluster.
182
158
183
- ``` bash
184
- swarm list zk://< zookeeper_addr1> ,< zookeeper_addr2> /< optional path prefix>
185
- < node_ip:2375>
186
- ```
159
+ swarm list zk://<zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix>
160
+ <node_ip:2375>
161
+
187
162
188
163
### Using a static list of IP addresses
189
164
190
165
Start the manager on any machine or your laptop
191
166
192
- ``` bash
193
- swarm manage -H < swarm_ip:swarm_port> nodes://< node_ip1:2375> ,< node_ip2:2375>
194
- ```
167
+ swarm manage -H <swarm_ip:swarm_port> nodes://<node_ip1:2375>,<node_ip2:2375>
195
168
196
169
Or
197
170
198
- ``` bash
199
- swarm manage -H < swarm_ip:swarm_port> < node_ip1:2375> ,< node_ip2:2375>
200
- ```
171
+ swarm manage -H <swarm_ip:swarm_port> <node_ip1:2375>,<node_ip2:2375>
172
+
201
173
202
174
Then use the regular Docker commands.
203
175
204
- ``` bash
205
- docker -H < swarm_ip:swarm_port> info
206
- docker -H < swarm_ip:swarm_port> run ...
207
- docker -H < swarm_ip:swarm_port> ps
208
- docker -H < swarm_ip:swarm_port> logs ...
209
- ...
210
- ```
176
+ docker -H <swarm_ip:swarm_port> info
177
+ docker -H <swarm_ip:swarm_port> run ...
178
+ docker -H <swarm_ip:swarm_port> ps
179
+ docker -H <swarm_ip:swarm_port> logs ...
180
+
211
181
212
182
### Range pattern for IP addresses
213
183
@@ -217,23 +187,19 @@ addresses, i.e., `10.0.0.[10:200]` will be a list of nodes starting from
217
187
218
188
For example for the ` file ` discovery method.
219
189
220
- ``` bash
221
- $ echo " 10.0.0.[11:100]:2375" >> /tmp/my_cluster
222
- $ echo " 10.0.1.[15:20]:2375" >> /tmp/my_cluster
223
- $ echo " 192.168.1.2:[2:20]375" >> /tmp/my_cluster
224
- ```
190
+ $ echo "10.0.0.[11:100]:2375" >> /tmp/my_cluster
191
+ $ echo "10.0.1.[15:20]:2375" >> /tmp/my_cluster
192
+ $ echo "192.168.1.2:[2:20]375" >> /tmp/my_cluster
225
193
226
194
Then start the manager.
227
195
228
- ``` bash
229
- swarm manage -H tcp://< swarm_ip:swarm_port> file:///tmp/my_cluster
230
- ```
196
+ swarm manage -H tcp://<swarm_ip:swarm_port> file:///tmp/my_cluster
197
+
231
198
232
199
And for the ` nodes ` discovery method.
233
200
234
- ``` bash
235
- swarm manage -H < swarm_ip:swarm_port> " nodes://10.0.0.[10:200]:2375,10.0.1.[2:250]:2375"
236
- ```
201
+ swarm manage -H <swarm_ip:swarm_port> "nodes://10.0.0.[10:200]:2375,10.0.1.[2:250]:2375"
202
+
237
203
238
204
## Contributing a new discovery backend
239
205
0 commit comments