Skip to content

Commit c431a2b

Browse files
committed
Fix #14 - Include Kubernetes, Remove Swarm, Update to Docker 1.9
1 parent 4572104 commit c431a2b

15 files changed

Lines changed: 2799 additions & 1257 deletions

attendees/docker-compose-internet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
mysqldb:
2-
image: classroom.example.com:5000/mysql
2+
image: mysql
33
environment:
44
MYSQL_DATABASE: sample
55
MYSQL_USER: mysql
66
MYSQL_PASSWORD: mysql
77
MYSQL_ROOT_PASSWORD: supersecret
88
mywildfly:
9-
image: classroom.example.com:5000/wildfly-mysql-javaee7
9+
image: arungupta/wildfly-mysql-javaee7
1010
links:
1111
- mysqldb:db
1212
ports:

chapters/docker-basics.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ These instructions are stored in a file called a Dockerfile. Docker reads this D
5252

5353
A container consists of an operating system, user-added files, and meta-data. As we've seen, each container is built from an image. That image tells Docker what the container holds, what process to run when the container is launched, and a variety of other configuration data. The Docker image is read-only. When Docker runs a container from an image, it adds a read-write layer on top of the image (using a union file system as we saw earlier) in which your application can then run.
5454

55-
### Docker Machine
55+
### Docker Machine (For Windows and Mac)
5656

5757
Machine makes it really easy to create Docker hosts on your computer, on cloud providers and inside your own data center. It creates servers, installs Docker on them, then configures the Docker client to talk to them.
5858

@@ -72,7 +72,7 @@ Check if docker machine is working:
7272

7373
It shows the output similar to the one shown below:
7474

75-
docker-machine version 0.4.1 (e2c88d6)
75+
docker-machine version 0.5.0 (04cfa58)
7676

7777
NOTE: The exact version may differ based upon how recently the installation was performed.
7878

@@ -86,7 +86,7 @@ Check if your client is working using the following command:
8686

8787
It shows the output similar to the following:
8888

89-
Docker version 1.8.2, build 0a8c2e3
89+
Docker version 1.9.0, build 76d6bc9
9090

9191
NOTE: The exact version may differ based upon how recently the installation was performed.
9292

chapters/docker-compose.adoc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ An application using Docker containers will typically consist of multiple contai
2828

2929
NOTE: According to https://docs.docker.com/compose/install/ "You can run Compose on OS X and 64-bit Linux. It is currently not supported on the Windows operating system."
3030

31-
### Install docker compose
31+
### Install docker compose (For Linux users)
3232

3333
[source, txt]
3434
----
35-
curl -L https://github.com/docker/compose/releases/download/1.4.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
36-
chmod +x /usr/local/bin/docker-compose
35+
sudo curl -L https://github.com/docker/compose/releases/download/1.5.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
36+
sudo chmod +x /usr/local/bin/docker-compose
3737
----
3838

3939
### Configuration File
@@ -43,21 +43,27 @@ chmod +x /usr/local/bin/docker-compose
4343
[source, yml]
4444
----
4545
mysqldb:
46-
image: [classroom.example.com:5000/]mysql
46+
#From Internet
47+
image: mysql
48+
#From Instructor
49+
image: classroom.example.com:5000/mysql
4750
environment:
4851
MYSQL_DATABASE: sample
4952
MYSQL_USER: mysql
5053
MYSQL_PASSWORD: mysql
5154
MYSQL_ROOT_PASSWORD: supersecret
5255
mywildfly:
53-
image: [classroom.example.com:5000|arungupta]/wildfly-mysql-javaee7
56+
#From Internet
57+
image: arungupta/wildfly-mysql-javaee7
58+
#From Instructor
59+
image: classroom.example.com:5000/wildfly-mysql-javaee7
5460
links:
5561
- mysqldb:db
5662
ports:
5763
- 8080
5864
----
5965
+
60-
This file is available in https://raw.githubusercontent.com/redhat-developer/docker-java/javaone2015/attendees/[] and shows:
66+
This file is available in https://raw.githubusercontent.com/redhat-developer/docker-java/devoxxma2015/attendees/[] and shows:
6167
+
6268
.. Two services defined by the name `mysqldb` and `mywildfly`
6369
.. Image name for each service defined using `image`

chapters/docker-container.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We call the union of the read-write layer and all the read-only layers a _union
4747
image::images/plain-wildfly0.png[]
4848
====
4949

50-
In our particular case, the https://github.com/jboss-dockerfiles/wildfly/blob/9.0.1.Final/Dockerfile[jboss/wildfly] image extends the https://github.com/jboss-dockerfiles/base-jdk/blob/jdk8/Dockerfile[jboss/base-jdk:8] image which adds the OpenJDK distribution on top of the https://github.com/jboss-dockerfiles/base/blob/master/Dockerfile[jboss/base] image.
50+
In our particular case, the https://github.com/jboss-dockerfiles/wildfly/blob/9.0.2.Final/Dockerfile[jboss/wildfly] image extends the https://github.com/jboss-dockerfiles/base-jdk/blob/jdk8/Dockerfile[jboss/base-jdk:8] image which adds the OpenJDK distribution on top of the https://github.com/jboss-dockerfiles/base/blob/master/Dockerfile[jboss/base] image.
5151
The base image is used for all JBoss community images. It provides a base layer that includes:
5252

5353
. A jboss user (uid/gid 1000) with home directory set to `/opt/jboss`
@@ -65,7 +65,6 @@ When the download is done, you can list the images again and will see the follow
6565
docker images
6666
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
6767
jboss/wildfly latest 7688aaf382ab 6 weeks ago 581.4 MB
68-
swarm latest 207e8b983242 9 weeks ago 10.2 MB
6968
----
7069

7170
### Run Container
@@ -104,7 +103,7 @@ This will show the output as:
104103
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
105104
17:02:58,000 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
106105
17:02:58,251 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
107-
17:02:58,311 INFO [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) starting
106+
17:02:58,311 INFO [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting
108107
17:02:59,558 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 11) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
109108
17:02:59,560 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 3) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
110109
...
@@ -114,7 +113,7 @@ OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was
114113
17:03:00,891 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
115114
17:03:01,131 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
116115
17:03:01,133 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
117-
17:03:01,138 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) started in 3431ms - Started 203 of 379 services (210 services are lazy, passive or on-demand)
116+
17:03:01,138 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 3431ms - Started 203 of 379 services (210 services are lazy, passive or on-demand)
118117
----
119118

120119
This shows that the server started correctly, congratulations!

chapters/docker-deployment-options.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ image::images/jbds1.png[]
8888
.WildFly Runtime Properties
8989
image::images/jbds2.png[]
9090
+
91-
. If a new runtime needs to be created, pick the directory for WildFly 9.0.1:
91+
. If a new runtime needs to be created, pick the directory for WildFly 9.0.2:
9292
+
93-
.WildFly 9.0.1.Final Runtime
93+
.WildFly 9.0.2.Final Runtime
9494
image::images/jbds3.png[]
9595
+
9696
Click on '`Finish`'.
@@ -141,7 +141,7 @@ TThe Command Line Interface (CLI) is a tool for connecting to WildFly instances
141141

142142
Lets use the CLI to deploy javaee7-simple-sample to WildFly running in the container.
143143

144-
. CLI needs to be locally installed and comes as part of WildFly. This should be available in the previously downloaded WildFly. Unzip into a folder of your choice (e.g. `/Users/<USER>/tools/`). This will create `wildfly-9.0.0.Final` directory here. This folder is referred to $WIDLFY_HOME from here on. Make sure to add the `/Users/<USER>/tools/wildfly-9.0.0.Final/bin` to your $PATH.
144+
. CLI needs to be locally installed and comes as part of WildFly. This should be available in the previously downloaded WildFly. Unzip into a folder of your choice (e.g. `/Users/<USER>/tools/`). This will create `wildfly-9.0.2.Final` directory here. This folder is referred to $WIDLFY_HOME from here on. Make sure to add the `/Users/<USER>/tools/wildfly-9.0.2.Final/bin` to your $PATH.
145145
+
146146
. Run the "`wildfly-management`" image with fixed port mapping as explained in <<Management_Fixed_Port_Mapping>>.
147147
. Run the `jboss-cli` command and connect to the WildFly instance.
@@ -240,7 +240,7 @@ docker run -d --name wildfly -p 8080:8080 -p 9990:9990 classroom.example.com:500
240240
+
241241
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.
242242
+
243-
. Create a new server adapter in JBoss Developer Studio and name it "`WildFly 9.0.0-Management`". Specify the host name as '`dockerhost`'.
243+
. Create a new server adapter in JBoss Developer Studio and name it "`WildFly 9.0.2-Management`". Specify the host name as '`dockerhost`'.
244244
+
245245
image::images/jbds8.png[]
246246
+

chapters/docker-image.adoc

Lines changed: 49 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -28,149 +28,97 @@ _Dockerfile_ is usually called _Dockerfile_. The complete list of commands that
2828

2929
. Create a new directory.
3030
. Create a new text file, name it _Dockerfile_, and use the following contents:
31-
+
31+
3232
[source, text]
3333
----
34-
FROM ubuntu
34+
#From Internet
35+
FROM fedora
36+
37+
#From Instructor
38+
FROM classroom.example.com:5000/fedora
3539
3640
CMD ["/bin/echo", "hello world"]
3741
----
38-
+
39-
This image uses `ubuntu` as the base image. `CMD` command defines the command that needs to run. It provides a different entry point of `/bin/echo` and gives the argument "`hello world`".
40-
+
42+
43+
This image uses `fedora` as the base image. `CMD` command defines the command that needs to run. It provides a different entry point of `/bin/echo` and gives the argument "`hello world`".
44+
4145
. Build this image:
42-
+
46+
4347
```console
4448
> docker build -t helloworld .
4549
Sending build context to Docker daemon 2.048 kB
46-
Step 0 : FROM ubuntu
47-
Pulling repository docker.io/library/ubuntu
48-
a5a467fddcb8: Download complete
49-
3fd0c2ae8ed2: Download complete
50-
9e19ac89d27c: Download complete
51-
ac65c371c3a5: Download complete
52-
Status: Downloaded newer image for ubuntu:latest
53-
---> a5a467fddcb8
54-
Step 1 : CMD /bin/echo hello world
55-
---> Running in 132bb0bf823f
56-
---> e81a394f71e3
57-
Removing intermediate container 132bb0bf823f
58-
Successfully built e81a394f71e3
50+
Step 1 : FROM fedora
51+
latest: Pulling from library/fedora
52+
369aca82a5c0: Pull complete
53+
a887c7ad7f3f: Pull complete
54+
Digest: sha256:a220110e096cd1d6034699a5e30a012de6c55c83149d01658120918d01f1587a
55+
Status: Downloaded newer image for fedora:latest
56+
---> a887c7ad7f3f
57+
Step 2 : CMD /bin/echo hello world
58+
---> Running in 47e65a18749c
59+
---> 405849ed68f1
60+
Removing intermediate container 47e65a18749c
61+
Successfully built 405849ed68f1
5962
```
60-
+
63+
6164
`.` in this command is the context for `docker build`.
62-
+
65+
6366
. List the images available:
64-
+
67+
6568
```console
6669
> docker images
6770
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
68-
helloworld latest 9c0e7b56cbee 13 minutes ago 187.9 MB
71+
helloworld latest 405849ed68f1 18 seconds ago 204.3 MB
72+
fedora latest a887c7ad7f3f 6 days ago 204.3 MB
6973
```
70-
+
74+
7175
. Run the container:
72-
+
76+
7377
docker run -it helloworld
74-
+
78+
7579
to see the output:
76-
+
80+
7781
hello world
78-
+
79-
. Change the base image from `ubuntu` to `busybox` in `Dockerfile`. Build the image again:
80-
+
82+
83+
. Change the base image from `fedora` to `busybox` in `Dockerfile`. Build the image again:
84+
8185
docker build -t helloworld2 .
82-
+
86+
8387
and view the images as:
84-
+
88+
8589
```console
8690
> docker images
87-
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
88-
helloworld latest e81a394f71e3 26 minutes ago 187.9 MB
89-
helloworld2 latest c458787fadcf 3 seconds ago 1.113 MB
90-
ubuntu latest a5a467fddcb8 2 days ago 187.9 MB
91-
busybox latest 3d5bcd78e074 4 days ago 1.113 MB
91+
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
92+
helloworld2 latest 3dece940fa4a 6 seconds ago 1.109 MB
93+
helloworld latest 405849ed68f1 About a minute ago 204.3 MB
94+
fedora latest a887c7ad7f3f 6 days ago 204.3 MB
95+
busybox latest c51f86c28340 8 days ago 1.109 MB
9296
```
9397

9498
=== WildFly Image
9599

96100
. Create a new directory.
97101
. Create a new text file, name it _Dockerfile_, and use the following contents:
98-
+
102+
99103
[source, text]
100104
----
105+
#From Internet
101106
FROM jboss/wildfly
102-
----
103-
+
104-
. Build the image:
105-
+
106-
docker build -t mywildfly .
107-
+
108-
. Run the container:
109-
+
110-
docker run -it mywildfly
111107
112-
=== Java EE 7 Application Image
113-
114-
. Create a new directory.
115-
. Create a new text file, name it _Dockerfile_, and use the following contents:
116-
+
117-
[source, text]
108+
#From Instructor
109+
FROM classroom.example.com:5000/wildfly
118110
----
119-
FROM jboss/wildfly <1>
120-
121-
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-c", "standalone-full.xml", "-b", "0.0.0.0"] <2>
122111

123-
RUN curl -L https://github.com/javaee-samples/javaee7-hol/raw/master/solution/movieplex7-1.0-SNAPSHOT.war -o /opt/jboss/wildfly/standalone/deployments/movieplex7-1.0-SNAPSHOT.war <3>
124-
----
125-
+
126-
Three things in this image:
127-
+
128-
<1> Uses "`jboss/wildfly`" as the base image
129-
<2> Starts WildFly application server in Full Platform mode
130-
<3> Copies the WAR file from from a URL to the deployment directory of WildFly
131-
+
132112
. Build the image:
133113

134-
docker build -t movieplex .
135-
136-
=== Dockerfile Command Design Patterns
137-
138-
==== Difference between CMD and ENTRYPOINT
139-
140-
*TL;DR* `CMD` will work for most of the cases.
141-
142-
Default entry point for a container is `/bin/sh`, the default shell.
143-
144-
Running a container as `docker run -it ubuntu` uses that command and starts the default shell. The output is shown as:
145-
146-
```console
147-
> docker run -it ubuntu
148-
root@88976ddee107:/#
149-
```
150-
151-
`ENTRYPOINT` allows to override the entry point to some other command, and even customize it. For example, a container can be started as:
152-
153-
```console
154-
> docker run -it --entrypoint=/bin/cat ubuntu /etc/passwd
155-
root:x:0:0:root:/root:/bin/bash
156-
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
157-
bin:x:2:2:bin:/bin:/usr/sbin/nologin
158-
sys:x:3:3:sys:/dev:/usr/sbin/nologin
159-
. . .
160-
```
161-
162-
This command overrides the entry point to the container to `/bin/cat`. The argument(s) passed to the CLI are used by the entry point.
163-
164-
==== Difference between ADD and COPY
114+
docker build -t mywildfly .
165115

166-
*TL;DR* `COPY` will work for most of the cases.
116+
. Run the container:
167117

168-
`ADD` has all capabilities of `COPY` and has the following additional features:
118+
docker run -it mywildfly
169119

170-
. Allows tar file auto-extraction in the image, for example, `ADD app.tar.gz /opt/var/myapp`.
171-
. Allows files to be downloaded from a remote URL. However, the downloaded files will become part of the image. This causes the image size to bloat. So its recommended to use `curl` or `wget` to download the archive explicitly, extract, and remove the archive.
172120

173-
==== Import and export images
121+
=== Import and export images
174122

175123
Docker images can be saved using `save` command to a .tar file:
176124

0 commit comments

Comments
 (0)