You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapters/docker-basics.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Docker has three main components:
24
24
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
25
26
26
.Docker architecture
27
-
image::docker-architecture.png[]
27
+
image::images/docker-architecture.png[]
28
28
29
29
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.
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
59
60
[source, text]
60
61
----
61
62
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
65
66
----
66
67
67
68
### Run Container
@@ -74,7 +75,8 @@ To run the WildFly container in an interactive mode.
74
75
75
76
[source, text]
76
77
----
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
78
80
----
79
81
80
82
This will show the output as:
@@ -121,7 +123,9 @@ Restart the container in detached mode:
121
123
122
124
[source, text]
123
125
----
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
@@ -146,8 +150,8 @@ We can check it by issuing the `docker ps` command which retrieves the images pr
146
150
[source, text]
147
151
----
148
152
> 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
151
155
----
152
156
153
157
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:
178
182
179
183
[source, text]
180
184
----
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
182
187
----
183
188
184
189
`-P` map any exposed ports inside the image to a random port on the Docker host. This can be verified as:
185
190
186
191
[source, text]
187
192
----
188
193
> 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
191
196
----
192
197
193
198
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:
207
212
208
213
[source, text]
209
214
----
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
211
217
----
212
218
213
219
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
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:
249
257
250
258
[source, text]
251
259
----
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
253
262
----
254
263
255
264
`-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:
259
268
[source, text]
260
269
----
261
270
docker ps
262
-
CONTAINER ID IMAGE COMMANDCREATEDSTATUS 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 COMMANDCREATEDSTATUSPORTS 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
265
274
----
266
275
267
276
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:
316
325
317
326
[source, text]
318
327
----
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
320
330
----
321
331
322
332
In this case, Docker port mapping will be shown as:
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.
44
53
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'
46
55
====
47
56
48
57
This command starts a container named "`wildfly`".
@@ -136,26 +145,27 @@ Start WildFly server as:
136
145
137
146
[source, text]
138
147
----
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
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[]
225
236
. Click on '`Next>`' and change the values as shown.
226
237
+
227
238
.Create New Server Adapter
228
-
image::jbds9.png[]
239
+
image::images/jbds9.png[]
229
240
+
230
241
. Take the default values in '`Remote System Integration`' and click on '`Finish`'.
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:
19
20
20
21
[source, text]
21
22
----
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
23
25
----
24
26
25
27
See the application in action at http://dockerhost:8080/movieplex7/. The output is shown:
0 commit comments