VOOZH about

URL: https://www.javacodegeeks.com/2014/12/create-your-own-docker-image-tech-tip-57.html

⇱ Create your own Docker image (Tech Tip #57)


Docker simplifies software delivery by making it easy to build and share images that contain your application’s entire environment, i.e. operating system, JDK, database, WAR file, specific tuning required for your application, etc.

There are three main components of Docker:
 
 
 
 
 
 

  • Docker images are “build component” – a read-only template of application operating system.
  • Containers are “run component” – a runtime representation created from images.
  • Registry are “distribution component” – a place to store and distribute images.

Several JBoss projects are available as Docker images at www.jboss.org/docker. Tech Tip #39 explained how to get started with Docker on Mac. It also explained how to start the official WildFly Docker image.

Docker image is made up of multiple layers where each layer provides some functionality, and a higher layer can add functionality on top of it. For example, Docker mounts the root filesystem as read-only layer and then adds a read-write layer on top of it. All these layers are combined together using Union Mount to provide application operating environment.

The complete history of how the WildFly image was built can be seen as:

docker history --no-trunc=true jboss/wildfly
IMAGE CREATED CREATED BY SIZE
365390553f925f96f8c00f79525ad101847de7781bb4fec23b1188f25fe99a6a 3 weeks ago /bin/sh -c #(nop) CMD [/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0] 0 B
d7fccab36b8f5a324ef8dd017c8964f2de7839379503021f15502ba3f0b908bd 3 weeks ago /bin/sh -c #(nop) EXPOSE map[8080/tcp:{} 9990/tcp:{}] 0 B
184d6d02f340455d33d226d6467484027d0763964a586ae9ada1782262299a74 3 weeks ago /bin/sh -c #(nop) ENV JBOSS_HOME=/opt/jboss/wildfly 0 B
57ada25ecdd03191355ec1c8f5f1a4e05b3e152709c9b603d5ed5fb0c4d53853 3 weeks ago /bin/sh -c cd $HOME && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly 135 MB
59ec65b61fba2b6ada099abe3a9a30d05ffb71370b43dfbd0208fd4f5a34c005 3 weeks ago /bin/sh -c #(nop) ENV WILDFLY_VERSION=8.1.0.Final 0 B
90832e1f0bb9e9f98ecd42f6df6b124c1e6768babaddc23d646cd75c7b2fddec 5 weeks ago /bin/sh -c #(nop) ENV JAVA_HOME=/usr/lib/jvm/java 0 B
72d585299bb5c5c1c326422cfffadc93d8bb4020f35bf072b2d91d287967807a 5 weeks ago /bin/sh -c #(nop) USER jboss 0 B
e02bdb6c4ed5436da02c958d302af5f06c1ebb1821791f60d45e190ebb55130f 5 weeks ago /bin/sh -c yum -y install java-1.7.0-openjdk-devel && yum clean all 217.2 MB
b17a20d6f5f8e7ed0a1dba277acd3f854c531b0476b03d63a8f0df4caf78c763 5 weeks ago /bin/sh -c #(nop) USER root 0 B
7759146eab1a3aa5ba5ed12483d03e64a6bf1061a383d5713a5e21fc40554457 5 weeks ago /bin/sh -c #(nop) MAINTAINER Marek Goldmann 

The exact command issued at each layer is listed in this output. If you scroll to the far right then you can see the total space consumed by each layer as well. For example, Fedora is used as the base image and consumes ~574 MB of the total image, Open JDK 7 is taking 217.5 MB and WildFly is 135 MB.

Docker images are built by reading the instructions from Dockerfile. This is a text file that contains all the commands, in order, needed to build a given image. It adheres to a specific format and use a specific set of instructions. The vocabulary of commands is rather limited but serves the purpose well. The image can be built by giving the command docker build. Docker Tutorial provides complete instructions on how to create your own custom image.

The official WildFly Docker image is built using Fedora 20 as the base operating system. The Dockerfile can be seen at github.com/jboss-dockerfiles/wildfly/blob/master/Dockerfile. It uses  jboss/base-jdk:7 as the base image, which uses jboss/base as the base image. Dockerfile of jboss/base shows Fedora 20 is used as the base image.

An alternative is to build this image using CentOS or Ubuntu as a base image. Dockerfiles for these images are available at github.com/arun-gupta/docker-images/.

Starting boot2docker shows the output as:

bash
unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
mkdir -p ~/.boot2docker
if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
/usr/local/bin/boot2docker init 
/usr/local/bin/boot2docker up 
$(/usr/local/bin/boot2docker shellinit)
docker version
Last login: Mon Nov 24 11:03:33 on ttys006
hello arungupta
~> bash
~> unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
~> mkdir -p ~/.boot2docker
~> if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
~> /usr/local/bin/boot2docker init 
Virtual machine boot2docker-vm already exists
~> /usr/local/bin/boot2docker up 
Waiting for VM and Docker daemon to start...
.....................ooooooooooooooooo
Started.
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/key.pem

To connect the Docker client to the Docker daemon, please set:
 export DOCKER_HOST=tcp://192.168.59.103:2376
 export DOCKER_CERT_PATH=/Users/arungupta/.boot2docker/certs/boot2docker-vm
 export DOCKER_TLS_VERIFY=1

~> $(/usr/local/bin/boot2docker shellinit)
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/key.pem
~> docker version
Client version: 1.3.1
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 4e9bbfa
OS/Arch (client): darwin/amd64
Server version: 1.3.1
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 4e9bbfa

And then you can build the CentOS-based WildFly Docker image as shown below. Note this command is given from the “wildfly-centos” directory of github.com/arun-gupta/docker-images/. And so the Dockerfile is at github.com/arun-gupta/docker-images/blob/master/wildfly-centos/Dockerfile.

wildfly-centos> docker build -t wildfly-centos .
Sending build context to Docker daemon 4.096 kB
Sending build context to Docker daemon 
Step 0 : FROM centos
centos:latest: The image you are pulling has been verified
511136ea3c5a: Pull complete 
5b12ef8fd570: Pull complete 
ae0c2d0bdc10: Pull complete 
Status: Downloaded newer image for centos:latest
 ---> ae0c2d0bdc10
Step 1 : MAINTAINER Arun Gupta <arungupta@redhat.com>
 ---> Running in 7fc52653d381
 ---> e490dfcb3685
Removing intermediate container 7fc52653d381
Step 2 : RUN yum -y update && yum clean all
 ---> Running in 90de23c9dde7
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.cc.columbia.edu
 * extras: centos.mirror.ndchost.com
 * updates: centos-distro.cavecreek.net
Resolving Dependencies
--> Running transaction check
---> Package tzdata.noarch 0:2014h-1.el7 will be updated
---> Package tzdata.noarch 0:2014j-1.el7_0 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package Arch Version Repository Size
================================================================================
Updating:
 tzdata noarch 2014j-1.el7_0 updates 434 k

Transaction Summary
================================================================================
Upgrade 1 Package

Total download size: 434 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/updates/packages/tzdata-2014j-1.el7_0.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for tzdata-2014j-1.el7_0.noarch.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package : centos-release-7-0.1406.el7.centos.2.5.x86_64 (@Updates/$releasever)
 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Updating : tzdata-2014j-1.el7_0.noarch 1/2 
 Cleanup : tzdata-2014h-1.el7.noarch 2/2 
 Verifying : tzdata-2014j-1.el7_0.noarch 1/2 
 Verifying : tzdata-2014h-1.el7.noarch 2/2 

Updated:
 tzdata.noarch 0:2014j-1.el7_0 

Complete!
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
 ---> f212cb9dbcf5
Removing intermediate container 90de23c9dde7
Step 3 : RUN yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all
 ---> Running in d4bd822933c8
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror-centos.hostingswift.com
 * extras: mirror.keystealth.org
 * updates: mirrors.advancedhosters.com
No package xmlstarlet available.
Resolving Dependencies
--> Running transaction check
---> Package augeas.x86_64 0:1.1.0-12.el7 will be installed
--> Processing Dependency: augeas-libs = 1.1.0-12.el7 for package: augeas-1.1.0-12.el7.x86_64

. . .

--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-6.el7_0.noarch
--> Running transaction check
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package Arch Version Repository Size
================================================================================
Installing:
 augeas x86_64 1.1.0-12.el7 base 35 k
 bsdtar x86_64 3.1.2-7.el7 base 55 k

. . .

 python-javapackages noarch 3.4.1-6.el7_0 updates 31 k
 python-lxml x86_64 3.2.1-4.el7 base 758 k

Transaction Summary
================================================================================
Install 4 Packages (+9 Dependent packages)

Total download size: 4.2 M
Installed size: 8.0 M
Downloading packages:
--------------------------------------------------------------------------------
Total 188 kB/s | 4.2 MB 00:22 
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : lzo-2.06-6.el7_0.2.x86_64 1/13 
 Installing : libxslt-1.1.28-5.el7.x86_64 

. . .

 Installing : unzip-6.0-13.el7.x86_64 13/13 
 Verifying : augeas-1.1.0-12.el7.x86_64 1/13 

. . .

 Verifying : javapackages-tools-3.4.1-6.el7_0.noarch 13/13 

Installed:
 augeas.x86_64 0:1.1.0-12.el7 bsdtar.x86_64 0:3.1.2-7.el7 
 saxon.noarch 0:9.3.0.4-11.el7 unzip.x86_64 0:6.0-13.el7 

Dependency Installed:
 augeas-libs.x86_64 0:1.1.0-12.el7 bea-stax.noarch 0:1.2.0-9.el7 
 bea-stax-api.noarch 0:1.2.0-9.el7 javapackages-tools.noarch 0:3.4.1-6.el7_0 
 libarchive.x86_64 0:3.1.2-7.el7 libxslt.x86_64 0:1.1.28-5.el7 
 lzo.x86_64 0:2.06-6.el7_0.2 python-javapackages.noarch 0:3.4.1-6.el7_0 
 python-lxml.x86_64 0:3.2.1-4.el7 

Complete!
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
 ---> 28b11e6151f0
Removing intermediate container d4bd822933c8
Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss
 ---> Running in 943c20ba5a51
 ---> 73603eab89b7
Removing intermediate container 943c20ba5a51
Step 5 : WORKDIR /opt/jboss
 ---> Running in 29c865c3109c
 ---> 9a661ae4341b
Removing intermediate container 29c865c3109c
Step 6 : USER jboss
 ---> Running in 7dfd8416ae2c
 ---> 6265153611c7
Removing intermediate container 7dfd8416ae2c
Step 7 : USER root
 ---> Running in a72588fba840
 ---> 12ed28a7acb7
Removing intermediate container a72588fba840
Step 8 : RUN yum -y install java-1.7.0-openjdk-devel && yum clean all
 ---> Running in 4efb3e17eb38
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.trouble-free.net
 * extras: centos.mirror.ndchost.com
 * updates: centos-distro.cavecreek.net
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el7_0 will be installed

. . .

---> Package hwdata.noarch 0:0.252-7.3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package Arch Version Repository
 Size
================================================================================
Installing:
 java-1.7.0-openjdk-devel x86_64 1:1.7.0.71-2.5.3.1.el7_0 updates 9.2 M
Installing for dependencies:
 alsa-lib x86_64 1.0.27.2-3.el7 base 389 k

. . .

144 k
 xorg-x11-font-utils x86_64 1:7.5-18.1.el7 base 87 k
 xorg-x11-fonts-Type1 noarch 7.5-9.el7 base 521 k

Transaction Summary
================================================================================
Install 1 Package (+73 Dependent packages)

Total download size: 49 M
Installed size: 181 M
Downloading packages:
--------------------------------------------------------------------------------
Total 1.7 MB/s | 49 MB 00:29 
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : freetype-2.4.11-9.el7.x86_64 1/74 
 Installing : libjpeg-turbo-1.2.90-5.el7.x86_64 2/74 

. . .

73/74 
 Installing : 1:java-1.7.0-openjdk-devel-1.7.0.71-2.5.3.1.el7_0.x86_64 74/74 
 Verifying : libsndfile-1.0.25-9.el7.x86_64 1/74 
 Verifying : libXfont-1.4.7-2.el7_0.x86_64 2/74 
 Verifying : kmod-14-9.el7.x86_64 

. . .

73/74 
 Verifying : gdk-pixbuf2-2.28.2-4.el7.x86_64 74/74 

Installed:
 java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el7_0 

Dependency Installed:
 alsa-lib.x86_64 0:1.0.27.2-3.el7 
 atk.x86_64 0:2.8.0-4.el7 

. . .
 
 xorg-x11-font-utils.x86_64 1:7.5-18.1.el7 
 xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 

Complete!
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
 ---> 44c4bb92fa11
Removing intermediate container 4efb3e17eb38
Step 9 : USER jboss
 ---> Running in 824d62c49182
 ---> 930cb2a860f7
Removing intermediate container 824d62c49182
Step 10 : ENV JAVA_HOME /usr/lib/jvm/java
 ---> Running in f19681365fe5
 ---> fff2c21b0a71
Removing intermediate container f19681365fe5
Step 11 : ENV WILDFLY_VERSION 8.2.0.Final
 ---> Running in cc9d42ece5c1
 ---> b7b7ca7a9172
Removing intermediate container cc9d42ece5c1
Step 12 : RUN cd $HOME && curl -O http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip
 ---> Running in 28e92a1b304f
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 126M 100 126M 0 0 813k 0 0:02:38 0:02:38 --:--:-- 644k
Archive: wildfly-8.2.0.Final.zip
 creating: wildfly-8.2.0.Final/
 creating: wildfly-8.2.0.Final/.installation/
 creating: wildfly-8.2.0.Final/appclient/
 creating: wildfly-8.2.0.Final/appclient/configuration/
 creating: wildfly-8.2.0.Final/bin/

. . .

 inflating: wildfly-8.2.0.Final/domain/configuration/application-users.properties 
 inflating: wildfly-8.2.0.Final/domain/configuration/mgmt-users.properties 
 inflating: wildfly-8.2.0.Final/standalone/configuration/application-users.properties 
 inflating: wildfly-8.2.0.Final/standalone/configuration/mgmt-users.properties 
 creating: wildfly-8.2.0.Final/domain/tmp/auth/
 creating: wildfly-8.2.0.Final/standalone/tmp/auth/
 ---> a1bc79a43c77
Removing intermediate container 28e92a1b304f
Step 13 : ENV JBOSS_HOME /opt/jboss/wildfly
 ---> Running in e3c995170046
 ---> d46fdd618d55
Removing intermediate container e3c995170046
Step 14 : EXPOSE 8080 9990
 ---> Running in d55d6a6f43cf
 ---> 6c17e2cefecf
Removing intermediate container d55d6a6f43cf
Step 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0
 ---> Running in 76e2630d16f5
 ---> 97c8780a7d6a
Removing intermediate container 76e2630d16f5
Successfully built 97c8780a7d6a

The list of Docker images can now be seen as:

wildfly-centos> docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
wildfly-centos latest 97c8780a7d6a 58 seconds ago 619.6 MB
centos latest ae0c2d0bdc10 2 weeks ago 224 MB

The total image size is 619.6 MB. The official WildFly Docker image can be installed as shown:

wildfly-centos> docker pull jboss/wildfly
Pulling repository jboss/wildfly
365390553f92: Download complete 
511136ea3c5a: Download complete 
782cf93a8f16: Download complete 
7d3f07f8de5f: Download complete 
1ef0a50fe8b1: Download complete 
20a1abe1d9bf: Download complete 
cd5bb934bb67: Download complete 
379edb00ab07: Download complete 
4d37cbbfc67d: Download complete 
2ea8562cac7c: Download complete 
7759146eab1a: Download complete 
b17a20d6f5f8: Download complete 
e02bdb6c4ed5: Download complete 
72d585299bb5: Download complete 
90832e1f0bb9: Download complete 
59ec65b61fba: Download complete 
57ada25ecdd0: Download complete 
184d6d02f340: Download complete 
d7fccab36b8f: Download complete 
Status: Downloaded newer image for jboss/wildfly:latest

And the complete list of Docker images can again be seen as:

wildfly-centos> docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
wildfly-centos latest 97c8780a7d6a 12 minutes ago 619.6 MB
centos latest ae0c2d0bdc10 2 weeks ago 224 MB
jboss/wildfly latest 365390553f92 4 weeks ago 948.7 MB

The image size in this case is 948.7 MB. A detailed understanding of this image is created was explained earlier in this blog.

Ubuntu-based WildFly image can be built and installed as shown below. Note this command is given from the “wildfly-ubuntu” directory of github.com/arun-gupta/docker-images/. And so the Dockerfile is at github.com/arun-gupta/docker-images/blob/master/wildfly-ubuntu/Dockerfile.

wildfly-ubuntu> docker build -t wildfly-ubuntu .
Sending build context to Docker daemon 4.096 kB
Sending build context to Docker daemon 
Step 0 : FROM ubuntu
ubuntu:latest: The image you are pulling has been verified
d497ad3926c8: Pull complete 
ccb62158e970: Pull complete 
e791be0477f2: Pull complete 
3680052c0f5c: Pull complete 
22093c35d77b: Pull complete 
5506de2b643b: Pull complete 
511136ea3c5a: Already exists 
Status: Downloaded newer image for ubuntu:latest
 ---> 5506de2b643b
Step 1 : MAINTAINER Arun Gupta 

The list of Docker images can once again be seen as:

wildfly-ubuntu> docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
wildfly-ubuntu latest 6a1c4acf3f78 5 minutes ago 749.5 MB
<none> <none> 1a5e1aeadc85 13 minutes ago 607.7 MB
wildfly-centos latest 97c8780a7d6a About an hour ago 619.6 MB
centos latest ae0c2d0bdc10 2 weeks ago 224 MB
jboss/wildfly latest 365390553f92 4 weeks ago 948.7 MB
ubuntu latest 5506de2b643b 4 weeks ago 199.3 MB

Docker image can run with docker run command. Some other related commands are:

  • docker ps: Lists containers
  • docker stop <id>: Stops the container with the given <id>

Run CentOS image as shown below. Specifying -i option will make it interactive and -t option allocates a pseudo-TTY. And port 8080 from the container is made accessible on port 80 of the container.

~> docker run -i -t -p 80:8080 wildfly-centos
=========================================================================

 JBoss Bootstrap Environment

 JBOSS_HOME: /opt/jboss/wildfly

 JAVA: /usr/lib/jvm/java/bin/java

 JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

22:20:52,769 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
22:20:53,038 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
22:20:53,120 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
22:20:54,176 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
22:20:54,197 INFO [org.xnio] (MSC service thread 1-10) XNIO version 3.3.0.Final
22:20:54,206 INFO [org.xnio.nio] (MSC service thread 1-10) XNIO NIO Implementation Version 3.3.0.Final
22:20:54,239 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
22:20:54,265 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
22:20:54,302 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
22:20:54,314 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
22:20:54,345 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
22:20:54,363 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
22:20:54,374 INFO [org.jboss.as.security] (MSC service thread 1-8) JBAS013170: Current PicketBox version=4.0.21.Final
22:20:54,419 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
22:20:54,486 INFO [org.jboss.as.connector.logging] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
22:20:54,573 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017502: Undertow 1.1.0.Final starting
22:20:54,579 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting
22:20:54,586 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
22:20:54,644 INFO [org.jboss.remoting] (MSC service thread 1-10) JBoss Remoting version 4.0.6.Final
22:20:54,658 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010417: Started Driver service with driver-name = h2
22:20:54,763 INFO [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
22:20:54,761 INFO [org.jboss.as.mail.extension] (MSC service thread 1-16) JBAS015400: Bound mail session 
22:20:56,387 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content
22:20:56,422 INFO [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017525: Started server default-server.
22:20:56,544 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017531: Host default-host starting
22:20:56,712 INFO [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
22:20:56,975 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-14) JBAS010400: Bound data source 
22:20:56,976 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-15) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
22:20:57,172 INFO [org.jboss.ws.common.management] (MSC service thread 1-10) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
22:20:57,239 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
22:20:57,240 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
22:20:57,241 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 4836ms - Started 184 of 234 services (82 services are lazy, passive or on-demand)

In a different shell, get the container’s IP address as:

~> boot2docker ip

The VM's Host only interface IP address is: 192.168.59.103

And then access WildFly at http://192.168.59.103.

Similarly, running the WildFly Ubuntu image shows:

wildfly-ubuntu> docker run -i -t -p 80:8080 wildfly-ubuntu
=========================================================================

 JBoss Bootstrap Environment

 JBOSS_HOME: /opt/jboss/wildfly

 JAVA: /usr/lib/jvm/java-7-openjdk-amd64/bin/java

 JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

22:34:07,612 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
22:34:07,911 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
22:34:07,996 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
22:34:09,076 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
22:34:09,097 INFO [org.xnio] (MSC service thread 1-9) XNIO version 3.3.0.Final
22:34:09,106 INFO [org.xnio.nio] (MSC service thread 1-9) XNIO NIO Implementation Version 3.3.0.Final
22:34:09,136 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
22:34:09,170 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
22:34:09,180 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
22:34:09,191 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
22:34:09,207 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
22:34:09,212 INFO [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.21.Final
22:34:09,230 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
22:34:09,317 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017502: Undertow 1.1.0.Final starting
22:34:09,317 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting
22:34:09,323 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
22:34:09,413 INFO [org.jboss.as.connector.logging] (MSC service thread 1-15) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
22:34:09,617 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
22:34:09,658 INFO [org.jboss.as.naming] (MSC service thread 1-10) JBAS011802: Starting Naming Service
22:34:09,674 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session 
22:34:09,692 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-12) JBAS010417: Started Driver service with driver-name = h2
22:34:09,693 INFO [org.jboss.remoting] (MSC service thread 1-9) JBoss Remoting version 4.0.6.Final
22:34:11,117 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content
22:34:11,134 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017525: Started server default-server.
22:34:11,206 INFO [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting
22:34:11,377 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
22:34:11,576 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
22:34:11,627 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source 
22:34:11,847 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
22:34:11,911 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
22:34:11,912 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
22:34:11,912 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 4762ms - Started 184 of 234 services (82 services are lazy, passive or on-demand)

You can login to the host VM as shown:

boot2docker ssh

Different layers of the image are stored in /var/lib/docker directory as shown:

docker-images> boot2docker ssh
 ## .
 ## ## ## ==
 ## ## ## ## ===
 /""""""""""""""""\___/ ===
 ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
 \______ o __/
 \ \ __/
 \____\______/
 _ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.3.2, build master : 495c19a - Mon Nov 24 20:40:58 UTC 2014
Docker version 1.3.2, build 39fa2fa
docker@boot2docker:~$ cd /var/lib/docker/
docker@boot2docker:/mnt/sda1/var/lib/docker$ ls -la
total 64
drwxr-xr-x 10 root root 4096 Nov 24 23:33 ./
drwxr-xr-x 4 root root 4096 Nov 24 19:15 ../
drwxr-xr-x 5 root root 4096 Nov 24 19:16 aufs/
drwx------ 17 root root 4096 Nov 24 23:33 containers/
drwx------ 3 root root 4096 Nov 24 19:16 execdriver/
drwx------ 84 root root 12288 Nov 24 23:28 graph/
drwx------ 2 root root 4096 Nov 25 14:50 init/
-rw-r--r-- 1 root root 11264 Nov 24 23:33 linkgraph.db
-rw------- 1 root root 565 Nov 24 23:28 repositories-aufs
drwx------ 2 root root 4096 Nov 24 23:28 tmp/
drwx------ 2 root root 4096 Nov 24 19:21 trust/
drwx------ 2 root root 4096 Nov 24 19:16 volumes/

VM image on Mac OSX is stored in ~/VirtualBox VMs/boot2docker-vm directory. This directory can grow up rather quickly if the intermediate containers are not removed. boot2docker-vm.vmdk on my machine is ~5GB for these different images.

You can reset it by running the following commands (WARNING: This will destroy all images you’ve downloaded and built so far):

boot2docker down
boot2docker destroy
boot2docker init
boot2docker up

Containers, as you can imagine, have a memory foot print.

More Docker goodness is coming in subsequent blogs!

Reference: Create your own Docker image from our JCG partner Arun Gupta at the Miles to go 2.0 … blog.
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

Tags
Docker
👁 Photo of Arun Gupta
Arun Gupta
December 19th, 2014Last Updated: December 18th, 2014
0 126 17 minutes read

Arun Gupta

Arun is a technology enthusiast, avid runner, author of a best-selling book, globe trotter, a community guy, Java Champion, JavaOne Rockstar, JUG Leader, Minecraft Modder, Devoxx4Kids-er, and a Red Hatter.
Subscribe

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button
Close
wpDiscuz