Skip to content

Commit 7badb1a

Browse files
committed
Fix #10 - Show an alternative path to run the lab using images from Docker Hub
1 parent db9a94f commit 7badb1a

10 files changed

Lines changed: 183 additions & 96 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
mysqldb:
2+
image: classroom.example.com:5000/mysql
3+
environment:
4+
MYSQL_DATABASE: sample
5+
MYSQL_USER: mysql
6+
MYSQL_PASSWORD: mysql
7+
MYSQL_ROOT_PASSWORD: supersecret
8+
mywildfly:
9+
image: classroom.example.com:5000/wildfly-mysql-javaee7
10+
links:
11+
- mysqldb:db
12+
ports:
13+
- 8080
14+

chapters/docker-basics.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Docker has three main components:
2424
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.
2525

2626
.Docker architecture
27-
image::docker-architecture.png[]
27+
image::images/docker-architecture.png[]
2828

2929
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.
3030

chapters/docker-compose.adoc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ chmod +x /usr/local/bin/docker-compose
4343
[source, yml]
4444
----
4545
mysqldb:
46-
image: classroom.example.com:5000/mysql
46+
image: [classroom.example.com:5000/]mysql
4747
environment:
4848
MYSQL_DATABASE: sample
4949
MYSQL_USER: mysql
5050
MYSQL_PASSWORD: mysql
5151
MYSQL_ROOT_PASSWORD: supersecret
5252
mywildfly:
53-
image: classroom.example.com:5000/wildfly-mysql-javaee7
53+
image: [classroom.example.com:5000|arungupta]/wildfly-mysql-javaee7
5454
links:
5555
- mysqldb:db
5656
ports:
5757
- 8080
5858
----
5959
+
60-
This file is available in https://raw.githubusercontent.com/redhat-developer/docker-java/javaone2015/attendees/docker-compose.yml[] and shows:
60+
This file is available in https://raw.githubusercontent.com/redhat-developer/docker-java/javaone2015/attendees/[] and shows:
6161
+
6262
.. Two services defined by the name `mysqldb` and `mywildfly`
6363
.. Image name for each service defined using `image`
@@ -67,6 +67,9 @@ This file is available in https://raw.githubusercontent.com/redhat-developer/doc
6767

6868
### Start Services
6969

70+
. Save the `docker-compose-internet.yml` as `docker-compose.yml` if you are running from Internet or
71+
. Save the `docker-compose-instructor.yml` as `docker-compose.yml` if you are using images from Instructor.
72+
7073
. All services can be started, in detached mode, by giving the command:
7174
+
7275
docker-compose up -d
@@ -100,7 +103,7 @@ Alternatively, the containers in this application, and any additional containers
100103
> docker ps
101104
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
102105
3598e545bd2f arungupta/wildfly-mysql-javaee7:latest "/opt/jboss/wildfly/ 59 seconds ago Up 58 seconds 0.0.0.0:32773->8080/tcp attendees_mywildfly_1
103-
b8cf6a3d518b mysql:latest "/entrypoint.sh mysq 2 minutes ago Up 2 minutes 3306/tcp attendees_mysqldb_1
106+
b8cf6a3d518b mysql:latest "/entrypoint.sh mysq 2 minutes ago Up 2 minutes 3306/tcp attendees_mysqldb_1
104107
----
105108
+
106109
. Service logs can be seen as:

chapters/docker-container-linking.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ This section will show how https://docs.docker.com/userguide/dockerlinks/[Docker
1212
+
1313
[source, text]
1414
----
15-
docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -p 3306:3306 -d classroom.example.com:5000/mysql
15+
docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -p 3306:3306 -d mysql #From Internet
16+
17+
docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -p 3306:3306 -d classroom.example.com:5000/mysql #From Instructor
1618
----
1719
+
1820
`-e` define environment variables that are read by the database at startup and allow us to access the database with this user and password.
@@ -21,7 +23,9 @@ docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_D
2123
+
2224
[source, text]
2325
----
24-
docker run -d --name mywildfly-mysql --link mysqldb:db -p 8080:8080 classroom.example.com:5000/wildfly-mysql-javaee7
26+
docker run -d --name mywildfly-mysql --link mysqldb:db -p 8080:8080 arungupta/wildfly-mysql-javaee7 #From Internet
27+
28+
docker run -d --name mywildfly-mysql --link mysqldb:db -p 8080:8080 classroom.example.com:5000/wildfly-mysql-javaee7 #From Instructor
2529
----
2630
+
2731
`--link` takes two parameters - first is name of the container we're linking to and second is the alias for the link name.

chapters/docker-container.adoc

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ At first, this list only contains the Docker swarm image, we used earlier.
1616
[source, text]
1717
----
1818
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
19-
classroom.example.com:5000/swarm latest 556c60f87888 33 hours ago 10.2 MB----
19+
swarm latest 556c60f87888 33 hours ago 10.2 MB
2020
----
2121

2222
Now, let's get a vanilla `jboss/wildfly` image:
2323

2424
[source, text]
2525
----
26-
docker pull classroom.example.com:5000/wildfly:latest
26+
docker pull jboss/wildfly:latest #From Internet
27+
docker pull classroom.example.com:5000/wildfly:latest #From Instructor
2728
----
2829

2930
By default, docker images are retrieved from https://hub.docker.com/[Docker Hub]. In our case, we're providing a so called private registry via the instructor laptop.
@@ -59,9 +60,9 @@ When the download is done, you can list the images again and will see the follow
5960
[source, text]
6061
----
6162
docker images
62-
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
63-
classroom.example.com:5000/wildfly latest 7688aaf382ab 6 weeks ago 581.4 MB
64-
classroom.example.com:5000/swarm latest 207e8b983242 9 weeks ago 10.2 MB
63+
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
64+
jboss/wildfly latest 7688aaf382ab 6 weeks ago 581.4 MB
65+
swarm latest 207e8b983242 9 weeks ago 10.2 MB
6566
----
6667

6768
### Run Container
@@ -74,7 +75,8 @@ To run the WildFly container in an interactive mode.
7475

7576
[source, text]
7677
----
77-
docker run -it classroom.example.com:5000/wildfly
78+
docker run -it jboss/wildfly #From Internet
79+
docker run -it classroom.example.com:5000/wildfly #From Instructor
7880
----
7981

8082
This will show the output as:
@@ -121,7 +123,9 @@ Restart the container in detached mode:
121123

122124
[source, text]
123125
----
124-
docker run --name mywildfly -d classroom.example.com:5000/wildfly
126+
docker run --name mywildfly -d jboss/wildfly #From Internet
127+
docker run --name mywildfly -d classroom.example.com:5000/wildfly #From Instructor
128+
125129
972f51cc8422eec0a7ea9a804a55a2827b5537c00a6bfd45f8646cb764bc002a
126130
----
127131

@@ -146,8 +150,8 @@ We can check it by issuing the `docker ps` command which retrieves the images pr
146150
[source, text]
147151
----
148152
> docker ps
149-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
150-
7da1c7614edf classroom.example.com:5000/wildfly "/opt/jboss/wildfly/ About a minute ago Up About a minute 8080/tcp mywildfly
153+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
154+
7da1c7614edf jboss/wildfly "/opt/jboss/wildfly/ About a minute ago Up About a minute 8080/tcp mywildfly
151155
----
152156

153157
Noticed the "NAMES" column? This is a quick way of refering to your container. Let's try to look at the logs again:
@@ -178,16 +182,17 @@ Restart the container as:
178182

179183
[source, text]
180184
----
181-
docker run --name mywildfly-exposed-ports -d -P classroom.example.com:5000/wildfly
185+
docker run --name mywildfly-exposed-ports -d -P jboss/wildfly #From Internet
186+
docker run --name mywildfly-exposed-ports -d -P classroom.example.com:5000/wildfly #From Instructor
182187
----
183188

184189
`-P` map any exposed ports inside the image to a random port on the Docker host. This can be verified as:
185190

186191
[source, text]
187192
----
188193
> docker ps
189-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
190-
7f41a5a0cfd6 classroom.example.com:5000/wildfly "/opt/jboss/wildfly/ 52 seconds ago Up 52 seconds 0.0.0.0:32768->8080/tcp mywildfly-exposed-ports
194+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
195+
7f41a5a0cfd6 jboss/wildfly "/opt/jboss/wildfly/ 52 seconds ago Up 52 seconds 0.0.0.0:32768->8080/tcp mywildfly-exposed-ports
191196
----
192197

193198
The port mapping is shown in the `PORTS` column. Access the WildFly server at http://dockerhost:32768. Make sure to use the correct port number as shown in your case.
@@ -207,7 +212,8 @@ Restart the container as:
207212

208213
[source, text]
209214
----
210-
docker run --name mywildfly-mapped-ports -d -p 8080:8080 classroom.example.com:5000/wildfly
215+
docker run --name mywildfly-mapped-ports -d -p 8080:8080 jboss/wildfly #From Internet
216+
docker run --name mywildfly-mapped-ports -d -p 8080:8080 classroom.example.com:5000/wildfly #From Instructor
211217
----
212218

213219
The format is `-p hostPort:containerPort`. This option maps container ports to host ports and allows other containers on our host to access them.
@@ -242,14 +248,17 @@ The following command will override the default command in Docker file, start Wi
242248

243249
[source, text]
244250
----
245-
docker run --name managed-wildfly -P -d classroom.example.com:5000/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0
251+
docker run --name managed-wildfly -P -d jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 #From Internet
252+
253+
docker run --name managed-wildfly -P -d classroom.example.com:5000/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 #From Instructor
246254
----
247255

248256
Accessing WildFly Administration Console require a user in administration realm. A pre-created image, with appropriate username/password credentials, is used to start WildFly as:
249257

250258
[source, text]
251259
----
252-
docker run --name managed-wildfly-from-image -P -d classroom.example.com:5000/wildfly-management
260+
docker run --name managed-wildfly-from-image -P -d rafabene/wildfly-admin #From Internet
261+
docker run --name managed-wildfly-from-image -P -d classroom.example.com:5000/wildfly-management #From Instructor
253262
----
254263

255264
`-P` map any exposed ports inside the image to a random port on Docker host.
@@ -259,9 +268,9 @@ Look at the exposed ports as:
259268
[source, text]
260269
----
261270
docker ps
262-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
263-
5fdedef5573b classroom.example.com:5000/wildfly-management "/bin/sh -c '/opt/jb 15 seconds ago Up 15 seconds 0.0.0.0:32772->8080/tcp, 0.0.0.0:32771->9990/tcp managed-wildfly-from-image
264-
ee30433b5414 classroom.example.com:5000/wildfly "/opt/jboss/wildfly/ 59 seconds ago Up 59 seconds 0.0.0.0:32769->8080/tcp managed-wildfly
271+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
272+
5fdedef5573b rafabene/wildfly-admin "/bin/sh -c '/opt/jb 15 seconds ago Up 15 seconds 0.0.0.0:32772->8080/tcp, 0.0.0.0:32771->9990/tcp managed-wildfly-from-image
273+
ee30433b5414 jboss/wildfly "/opt/jboss/wildfly/ 59 seconds ago Up 59 seconds 0.0.0.0:32769->8080/tcp managed-wildfly
265274
----
266275

267276
Look for the host port that is mapped in the container, `32769` in this case. Access the admin console at http://dockerhost:32769.
@@ -316,7 +325,8 @@ This management image can also be started with a pre-defined port mapping as:
316325

317326
[source, text]
318327
----
319-
docker run -p 8080:8080 -p 9990:9990 -d classroom.example.com:5000/wildfly-management
328+
docker run -p 8080:8080 -p 9990:9990 -d rafabene/wildfly-admin #From Internet
329+
docker run -p 8080:8080 -p 9990:9990 -d classroom.example.com:5000/wildfly-management #From Instructor
320330
----
321331

322332
In this case, Docker port mapping will be shown as:

chapters/docker-deployment-options.adoc

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ We're going to build the application first.
99

1010
. Clone the repo:
1111

12-
git clone http://root:dockeradmin@classroom.example.com:10080/root/javaee7-simple-sample.git
12+
git clone https://github.com/javaee-samples/javaee7-simple-sample.git #From Internet
13+
git clone http://root:dockeradmin@classroom.example.com:10080/root/javaee7-simple-sample.git #From Instructor
14+
1315

1416
. Build the application:
1517

1618
[source, text]
1719
----
1820
cd javaee7-simple-sample/
21+
22+
#From Internet
23+
mvn clean package
24+
25+
#From Instructor
1926
curl http://classroom.example.com:8082/downloads/lab-settings.xml -o settings.xml
2027
mvn -s settings.xml clean package
2128
----
@@ -35,14 +42,16 @@ Start WildFly server as:
3542

3643
[source, text]
3744
----
38-
docker run --name wildfly -d -p 8080:8080 -v `pwd`/deployments:/opt/jboss/wildfly/standalone/deployments/:rw classroom.example.com:5000/wildfly
45+
docker run --name wildfly -d -p 8080:8080 -v `pwd`/deployments:/opt/jboss/wildfly/standalone/deployments/:rw jboss/wildfly #From Internet
46+
47+
docker run --name wildfly -d -p 8080:8080 -v `pwd`/deployments:/opt/jboss/wildfly/standalone/deployments/:rw classroom.example.com:5000/wildfly #From Instructor
3948
----
4049

4150
[NOTE]
4251
====
4352
Windows users need to tweak this a bit and copy the deployments to c:/Users/<USER>/deployments because the directory mappings for boot2docker work differently on those systems. Please update the docker -v argument accordingly.
4453
45-
'docker run --name wildfly -d -p 8080:8080 -v /c/Users/meisele/deployments:/opt/jboss/wildfly/standalone/deployments/:rw classroom.example.com:5000/wildfly'
54+
'docker run --name wildfly -d -p 8080:8080 -v /c/Users/meisele/deployments:/opt/jboss/wildfly/standalone/deployments/:rw [classroom.example.com:5000|jboss]/wildfly'
4655
====
4756

4857
This command starts a container named "`wildfly`".
@@ -136,26 +145,27 @@ Start WildFly server as:
136145

137146
[source, text]
138147
----
139-
docker run --name wildfly-managed -d -p 8080:8080 -p 9990:9990 classroom.example.com:5000/wildfly
148+
docker run --name wildfly-managed -d -p 8080:8080 -p 9990:9990 rafabene/wildfly-admin #From Internet
149+
docker run --name wildfly-managed -d -p 8080:8080 -p 9990:9990 classroom.example.com:5000/wildfly-management #From Instructor
140150
----
141151

142152
This command starts a container named "`wildfly-managed`".
143153

144-
+
154+
145155
[source, text]
146156
----
147157
jboss-cli.sh --controller=dockerhost:9990 -u=admin -p=docker#admin -c
148158
----
149-
+
159+
150160
This will show the output as:
151-
+
161+
152162
[source, text]
153163
----
154164
[standalone@dockerhost:9990 /]
155165
----
156-
+
166+
157167
. Deploy the application as:
158-
+
168+
159169
[source, text]
160170
----
161171
deploy <javaee7-simple-sample PATH>target/javaee7-simple-sample-1.10.war --force
@@ -213,7 +223,8 @@ A standalone WildFly process, process can be configured to listen for remote man
213223
+
214224
[source, text]
215225
----
216-
docker run -d --name wildfly -p 8080:8080 -p 9990:9990 classroom.example.com:5000/wildfly-management
226+
docker run -d --name wildfly -p 8080:8080 -p 9990:9990 rafabene/wildfly-admin #From Internet
227+
docker run -d --name wildfly -p 8080:8080 -p 9990:9990 classroom.example.com:5000/wildfly-management #From Instructor
217228
----
218229
+
219230
In addition to application port 8080, the administration port 9990 is exposed as well. The WildFly image that is used has tweaked the start script such that the management interface is bound to 0.0.0.0.
@@ -225,7 +236,7 @@ image::images/jbds8.png[]
225236
. Click on '`Next>`' and change the values as shown.
226237
+
227238
.Create New Server Adapter
228-
image::jbds9.png[]
239+
image::images/jbds9.png[]
229240
+
230241
. Take the default values in '`Remote System Integration`' and click on '`Finish`'.
231242
+

chapters/docker-javaee7.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Pull the Docker image that contains WildFly and pre-built Java EE 7 application
1010

1111
[source, text]
1212
----
13-
docker pull classroom.example.com:5000/javaee7-hol
13+
docker pull arungupta/javaee7-hol #From Internet
14+
docker pull classroom.example.com:5000/javaee7-hol #From Instructor
1415
----
1516

1617
The https://github.com/arun-gupta/docker-images/blob/master/javaee7-hol/Dockerfile[javaee7-hol Dockerfile] is based on `jboss/wildfly` and adds the movieplex7 application as war file.
@@ -19,7 +20,8 @@ Run it:
1920

2021
[source, text]
2122
----
22-
docker run -it -p 8080:8080 classroom.example.com:5000/javaee7-hol
23+
docker run -it -p 8080:8080 arungupta/javaee7-hol #From Internet
24+
docker run -it -p 8080:8080 classroom.example.com:5000/javaee7-hol #From Instructor
2325
----
2426

2527
See the application in action at http://dockerhost:8080/movieplex7/. The output is shown:

0 commit comments

Comments
 (0)