Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -370,6 +370,7 @@ access to the network. |
| 370 | 370 |
When you create a service and pass the --network flag to attach the service to |
| 371 | 371 |
the overlay network: |
| 372 | 372 |
|
| 373 |
+```bash |
|
| 373 | 374 |
$ docker service create \ |
| 374 | 375 |
--replicas 3 \ |
| 375 | 376 |
--network my-network \ |
| ... | ... |
@@ -377,6 +378,8 @@ $ docker service create \ |
| 377 | 377 |
nginx |
| 378 | 378 |
|
| 379 | 379 |
716thylsndqma81j6kkkb5aus |
| 380 |
+``` |
|
| 381 |
+ |
|
| 380 | 382 |
The swarm extends my-network to each node running the service. |
| 381 | 383 |
|
| 382 | 384 |
Containers on the same network can access each other using |
| ... | ... |
@@ -388,13 +391,13 @@ You can publish service ports to make them available externally to the swarm |
| 388 | 388 |
using the `--publish` flag: |
| 389 | 389 |
|
| 390 | 390 |
```bash |
| 391 |
-docker service create --publish <TARGET-PORT>:<SERVICE-PORT> nginx |
|
| 391 |
+$ docker service create --publish <TARGET-PORT>:<SERVICE-PORT> nginx |
|
| 392 | 392 |
``` |
| 393 | 393 |
|
| 394 | 394 |
For example: |
| 395 | 395 |
|
| 396 | 396 |
```bash |
| 397 |
-docker service create --name my_web --replicas 3 --publish 8080:80 nginx |
|
| 397 |
+$ docker service create --name my_web --replicas 3 --publish 8080:80 nginx |
|
| 398 | 398 |
``` |
| 399 | 399 |
|
| 400 | 400 |
When you publish a service port, the swarm routing mesh makes the service |