Skip to content

Commit 7f8e7be

Browse files
committed
Merge pull request #142 from chscorpio/readme-fixes
Readme fixes
2 parents e07f668 + 8c860f1 commit 7f8e7be

File tree

4 files changed

+41
-55
lines changed

4 files changed

+41
-55
lines changed

chapters/docker-basics.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ You can certainly provide an installation script that will download and install
1818

1919
Docker has three main components:
2020

21-
. __Images__ are *build component* of Docker and a read-only template of application operating system.
22-
. __Containers__ are *run component* of Docker, and created from, images.Containers can be run, started, stopped, moved, and deleted.
23-
. Images are stored, shared, and managed in a __registry__, the *distribution component* of Docker. The publically available registry is known as Docker Hub (available at http://hub.docker.com).
21+
. __Images__ are the *build component* of Docker and are the read-only templates defining an application operating system.
22+
. __Containers__ are the *run component* of Docker and created from images. Containers can be run, started, stopped, moved, and deleted.
23+
. Images are stored, shared, and managed in a __registry__ and are the *distribution component* of Docker. Docker Hub is a publicly available registry and is available at http://hub.docker.com.
2424

25-
In order for these three components to work together, there is *Docker Daemon* that runs on a host machine and does the heavy lifting of building, running, and distributing Docker containers. In addition, there is *Client* that is a Docker binary which accepts commands from the user and communicates back and forth with the daemon.
25+
In order for these three components to work together, the *Docker Daemon* runs on a host machine and does the heavy lifting of building, running, and distributing Docker containers. In addition, the *Client* is a Docker binary which accepts commands from the user and communicates back and forth with the Daemon.
2626

2727
.Docker architecture
2828
image::docker-architecture.png[]
2929

30-
Client communicates with Daemon, either co-located on the same host, or on a different host. It requests the Daemon to pull an image from the repository using `pull` command. The Daemon then downloads the image from Docker Hub, or whatever registry is configured. Multiple images can be downloaded from the registry and installed on Daemon host. Images are run using `run` command to create containers on demand.
30+
The Client communicates with a Daemon that is either co-located on the same host or on a different host. Use the `pull` command on the Client to request the Daemon to pull an image from the registry. The Daemon then downloads the image from Docker Hub, or whichever registry is configured. Multiple images can be downloaded from the registry and installed on the Daemon host. To run an Image, use the `run` command on the Client to request the Daemon to create a container on-demand based on the image.
3131

3232
**How does a Docker Image work?**
3333

chapters/docker-preface.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Containers are enabling developers to package their applications (and underlying
44

55
Docker is the developer-friendly Linux container technology that enables creation of your stack: OS, JVM, app server, app, and all your custom configuration. So with all it offers, how comfortable are you and your team taking Docker from development to production? Are you hearing developers say, “But it works on my machine!” when code breaks in production?
66

7-
This lab offers developers an intro-level, hands-on session with Docker, from installation, to exploring Docker Hub, to crafting their own images, to adding Java apps and running custom containers. It will also explain how to use Swarm to orchesorchestrate these containers together. This is a BYOL (bring your own laptop) session, so bring your Windows, OSX, or Linux laptop and be ready to dig into a tool that promises to be at the forefront of our industry for some time to come.
7+
This lab offers developers an intro-level, hands-on session with Docker, from installation, to exploring Docker Hub, to crafting their own images, to adding Java apps and running custom containers. It will also explain how to use Swarm to orchestrate these containers together. This is a BYOL (bring your own laptop) session, so bring your Windows, OSX, or Linux laptop and be ready to dig into a tool that promises to be at the forefront of our industry for some time to come.
88

99
NOTE: Latest content of this workshop is always at https://github.com/javaee-samples/docker-java

chapters/docker-setup.adoc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,6 @@ IMPORTANT: For Mac and Windows, this commands need to be issued from the Docker
3737
docker-compose -f docker-compose-pull-images.yml pull
3838
```
3939

40-
#### Create Docker Swarm Cluster
41-
42-
Create Docker Swarm cluster as:
43-
44-
```console
45-
docker run swarm create
46-
```
47-
48-
This will generate a token.
49-
50-
IMPORTANT: Save the token generated by this command as it cannot be queried/recovered later.
51-
52-
Use this token to create a Swarm Master.
53-
54-
```console
55-
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://<token> swarm-master
56-
```
57-
Detailed explanation for this is available in <<Docker_Swarm>>.
58-
5940
#### Create Docker Host Mapping
6041

6142
. To make it easier to start/stop the containers, an entry is added into the host mapping table of your operating system. Find out the IP address of your machine:

chapters/docker-swarm.adoc

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
[[Docker_Swarm]]
22
## Deploy Application on Docker Swarm Cluster
33

4-
Docker Swarm is native clustering for Docker. It allows you create and access to a pool of Docker hosts using the full suite of Docker tools. Because Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.
4+
Docker Swarm is native clustering for Docker. It allows you to create and access a pool of Docker hosts using the full suite of Docker tools. Because Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.
55

66
### Key Components of Docker Swarm
77

88
.Key Components of Docker Swarm
99
image::docker-swarm-components.png[]
1010

11-
*Swarm Manager*: Docker Swarm has a Manager, that is a pre-defined Docker Host, and is a single point for all administration. Swarm manager orchestrates and schedules containers on the entire cluster. Swarm Manager can be configured in https://docs.docker.com/swarm/multi-manager-setup/[High Availability].
11+
*Swarm Manager*: Docker Swarm has a Manager that is a pre-defined Docker Host and is a single point for all administration. Swarm manager orchestrates and schedules containers in the entire cluster. Swarm Manager can be configured to enable https://docs.docker.com/swarm/multi-manager-setup/[High Availability].
1212

1313
*Swarm Nodes*: The containers are deployed on Nodes that are additional Docker Hosts. Each Swarm Node must be accessible by the manager, each node must listen to the same network interface (TCP port). Each node runs a Docker Swarm agent that registers the referenced Docker daemon, monitors it, and updates the discovery backend with the node’s status. The containers run on a node.
1414

1515
*Scheduler Strategy*: Different scheduler strategies ("`binpack`", "`spread`" (default), and "`random`") can be applied to pick the best node to run your container. The default strategy optimizes the node for least number of running containers. There are multiple kinds of filters, such as constraints and affinity. This should allow for a decent scheduling algorithm.
1616

17-
*Node Discovery Service*: Swarm manager talks to a hosted discovery service. This service maintains a list of IPs in Swarm cluster. Docker Hub hosts a discovery service that can be used during development. In production, this is replaced by other services such as `etcd`, `consul`, or `zookeeper`. You can even use a static file. This is particularly useful if there is no access to Internet, or you are running the setup in a closed network.
17+
*Node Discovery Service*: Swarm manager talks to a hosted discovery service. This service maintains a list of IPs in the Swarm cluster. Docker Hub hosts a discovery service that can be used during development. In production, this is replaced by other services such as `etcd`, `consul`, or `zookeeper`. You can even use a static file. This is particularly useful if there is no Internet access or you are running in a closed network.
1818

19-
**Standard Docker API:** Docker Swarm serves the standard Docker API and thus any tool that talks to a single Docker host will seamlessly scale to multiple hosts now. That means that if you were using shell scripts using Docker CLI to configure multiple Docker hosts, the same CLI would can now talk to Swarm cluster.
19+
*Standard Docker API*: Docker Swarm serves the standard Docker API and thus any tool that talks to a single Docker host will seamlessly scale to multiple hosts now. That means that if you were using shell scripts using Docker CLI to configure multiple Docker hosts, the same CLI could now talk to the Swarm cluster.
2020

2121
There are a lots of other concepts but these are the main ones.
2222

23-
This section will deploy an application that will provide a CRUD/REST interface on a data bucket in Couchbase. This is achieved by using a Java EE application deployed on WildFly and accessing the database.
23+
This section will deploy an application that will provide a CRUD/REST interface on a data bucket in Couchbase. This is achieved by using a Java EE application deployed on WildFly to access the database.
2424

2525
### Create Discovery Service
2626

@@ -140,13 +140,13 @@ docker-machine inspect --format='{{json .Driver}}' swarm-master
140140
+
141141
Note that the disk size is 5GB.
142142
+
143-
. Connect to the master by using the command:
143+
. Connect to the Swarm cluster by using the command:
144144
+
145145
eval "$(docker-machine env --swarm swarm-master)"
146146
+
147-
NOTE: If you're on Windows, use the `docker-machine env swarm-master` command only and copy the output into an editor to replace all appearances of EXPORT with SET and issue the three commands at your command prompt, remove the quotes and all duplicate appearences of "/".
147+
NOTE: `--swarm` is specified to connect to the Swarm cluster. Otherwise the command will connect to `swarm-master` Machine only. However, if you're on Windows, then use the `docker-machine env swarm-master` command only. Then copy the output into an editor to replace all appearances of EXPORT with SET, remove the quotes, and all appearances of "/" with "\". Finally, issue the three commands at your command prompt.
148148
+
149-
. Find some information about the cluster:
149+
. Get information about the cluster:
150150
+
151151
[source, text]
152152
----
@@ -169,7 +169,7 @@ Name: d074fd97682e
169169
+
170170
This cluster has one node and that node has two containers.
171171
+
172-
. Create a new Machine to join this cluster:
172+
. Create the first Swarm node to join this cluster:
173173
+
174174
[source, text]
175175
----
@@ -219,16 +219,9 @@ swarm-node-01 - virtualbox Running tcp://192.168.99.102:2376 swa
219219
swarm-node-02 - virtualbox Running tcp://192.168.99.103:2376 swarm-master
220220
----
221221
+
222-
The machines that are part of the cluster have cluster’s name in the SWARM column, blank otherwise. For example, `consul-machine` is a standalone machine where as all other machines are part of the `swarm-master` cluster. The Swarm master is also identified by (master) in the SWARM column.
222+
The machines that are part of the cluster have cluster’s name in the SWARM column. If the SWARM column is blank, then it is a standalone machine. For example, `consul-machine` is a standalone machine as opposed to all other machines which are part of the `swarm-master` cluster. The Swarm master is identified by (master) in the SWARM column.
223223
+
224-
. Connect to the Swarm cluster and find some information about it:
225-
226-
eval "$(docker-machine env --swarm swarm-master)"
227-
docker info
228-
+
229-
Note, `--swarm` is specified to connect to the Swarm cluster. Otherwise the command will connect to `swarm-master` Machine only.
230-
+
231-
This shows the output as:
224+
. Get information about the cluster again:
232225
+
233226
[source, text]
234227
----
@@ -259,9 +252,18 @@ Total Memory: 3.064 GiB
259252
Name: d074fd97682e
260253
----
261254
+
262-
There are 3 nodes – one Swarm master and 2 Swarm _worker_ nodes. There is a total of 4 containers running in this cluster – one Swarm agent on master and each node, and there is an additional swarm-agent-master running on the master. This can be verified by connecting to the master and listing all the containers.
255+
Now there are 3 nodes – one Swarm master and 2 Swarm _worker_ nodes. There are a total of 4 containers running in this cluster – a swarm-agent on each node and an additional swarm-agent-master running on the master. This can be verified by connecting to the master Machine (without specifying `--swarm`) and listing all the containers:
256+
+
257+
[source, text]
258+
----
259+
eval "$(docker-machine env swarm-master)"
260+
docker ps
261+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
262+
cf5edbf4ada7 swarm:latest "/swarm join --advert" 49 seconds ago Up 49 seconds 2375/tcp swarm-agent
263+
c7c3b80bceb4 swarm:latest "/swarm manage --tlsv" 49 seconds ago Up 49 seconds 2375/tcp, 0.0.0.0:3376->3376/tcp swarm-agent-master
264+
----
263265
+
264-
. List nodes in the cluster with the following command:
266+
. You can also query the Consul discovery service while connected to the Swarm cluster, master, or any worker node in the cluster to list the nodes in the cluster:
265267
+
266268
[source, text]
267269
----
@@ -273,8 +275,10 @@ docker run swarm list consul://$(docker-machine ip consul-machine):8500
273275

274276
### Start Application Environment Using Docker Compose
275277

276-
Make sure you are connected to the cluster by giving the command `eval "$(docker-machine env --swarm swarm-master)"`.
277-
278+
. Connect to the Swarm cluster:
279+
+
280+
eval "$(docker-machine env --swarm swarm-master)"
281+
+
278282
. List all the networks created by Docker so far:
279283
+
280284
[source, text]
@@ -292,7 +296,7 @@ d2f3b512f9dc swarm-node-01/bridge bridge
292296
fffc34eae907 swarm-master/host host
293297
----
294298
+
295-
Docker create three networks for each host automatically:
299+
Docker creates three networks for each host automatically:
296300
+
297301
[options="header", cols="1,3", width="80%"]
298302
|====
@@ -302,7 +306,7 @@ Docker create three networks for each host automatically:
302306
| `host` | Adds a container on hosts networking stack. Network configuration is identical to the host.
303307
|====
304308
+
305-
This explains a total of nine networks, three for each node, as shown in this Swarm cluster.
309+
A total of nine networks are created for this three-node Swarm cluster because three networks are created for each node.
306310
+
307311
. Use Compose file to start WildFly and Couchbase:
308312
+
@@ -420,22 +424,23 @@ As seen, `wildflycouchbasejavaee7` overlay network exists on all Machines. This
420424
+
421425
Read more about https://docs.docker.com/engine/userguide/networking/dockernetworks/[Docker Networks].
422426
+
423-
. Verify that WildFly and Couchbase are running:
427+
. Connect to the Swarm cluster and verify that WildFly and Couchbase are running:
424428
+
425429
[source, text]
426430
----
431+
eval "$(docker-machine env --swarm swarm-master)"
427432
docker ps
428433
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
429434
23a581295a2b couchbase/server "/entrypoint.sh couch" 9 seconds ago Up 8 seconds 192.168.99.102:8091-8093->8091-8093/tcp, 11207/tcp, 11211/tcp, 192.168.99.102:11210->11210/tcp, 18091-18092/tcp swarm-master/db
430435
7a8a885b23f3 arungupta/wildfly-admin "/opt/jboss/wildfly/b" 9 seconds ago Up 8 seconds 192.168.99.103:8080->8080/tcp, 192.168.99.103:9990->9990/tcp swarm-node-01/wildflycouchbasejavaee7_mywildfly_1
431436
----
432437
+
433-
Note that Couchbase server is running on `swarm-master` node and WildFly is running on `swarm-node-01`.
438+
Note that, in this example, the Couchbase server is running on `swarm-master` node and WildFly is running on `swarm-node-01`. Take a note on which nodes your Couchbase and WildFly servers are running and update the following commands accordingly.
434439

435440
### Configure Couchbase server
436441

437442
. Clone https://github.com/arun-gupta/couchbase-javaee.git. This workspace contains a simple Java EE application that is deployed on WildFly and provides a REST API over `travel-sample` bucket in Couchbase.
438-
. Couchbase server can be configured using http://developer.couchbase.com/documentation/server/4.0/rest-api/rest-endpoints-all.html[REST API]. The application contains a Maven profile that allows to configure Couchbase server with `travel-sample` bucket. This can be invoked as:
443+
. Couchbase server can be configured using http://developer.couchbase.com/documentation/server/4.0/rest-api/rest-endpoints-all.html[REST API]. The application contains a Maven profile that allows to configure the Couchbase server with `travel-sample` bucket. This can be invoked as: (Note that you may need to replace `swarm-master` with the node in your cluster that is running Couchbase)
439444
+
440445
[source, text]
441446
----
@@ -462,7 +467,7 @@ mvn install -Pcouchbase -Ddocker.host=$(docker-machine ip swarm-master)
462467

463468
Deploy the application to WildFly by specifying three parameters:
464469

465-
. Host IP address where WildFly is running
470+
. Host IP address where WildFly is running (swarm-node-01 in this example but update as needed for your cluster)
466471
. Username of a user in WildFly's administrative realm
467472
. Password of the user specified in WildFly's administrative realm
468473

@@ -488,7 +493,7 @@ INFO: JBoss Remoting version 4.0.9.Final
488493

489494
### Access Application
490495

491-
Now that WildFly and Couchbase server have started, lets access the application. You need to specify IP address of the Machine where WildFly is running:
496+
Now that the WildFly and Couchbase servers have started, lets access the application. You need to specify the IP address of the Machine where WildFly is running (swarm-node-01 in this example but update as needed for your cluster):
492497

493498
[source, text]
494499
----
@@ -498,4 +503,4 @@ curl http://$(docker-machine ip swarm-node-01):8080/couchbase-javaee/resources/a
498503

499504
Check state of the cluster by connecting to different nodes.
500505

501-
Add container visualiation using https://github.com/javaee-samples/docker-java/issues/55.
506+
Add container visualization using https://github.com/javaee-samples/docker-java/issues/55.

0 commit comments

Comments
 (0)