Javaee&docker Container Example

Source: Internet
Author: User
Tags jboss wildfly

Preparation: JBoss, JDK, a Java EE War pack, Dockerfile

Note: JBoss and JDK can not be prepared in advance, wget in the command, because I happen to have, directly copied

Dockerfile content:

#admln 20150120
From ubuntu:14.04
Maintainer admln <[email protected]>
RUN Mkdir/usr/jboss
COPY wildfly-8.2.0.final/usr/jboss/
COPY javaeedocker.war/usr/jboss/standalone/deployments/
RUN mkdir/usr/java/
COPY jdk-7u71-linux-x64.tar.gz/usr/java/
workdir/usr/java/
RUN TAR-ZXF jdk-7u71-linux-x64.tar.gz
RUN update-alternatives--install/usr/bin/javac Javac/usr/java/jdk1.7.0_71/bin
/javac 100
RUN update-alternatives--install/usr/bin/java java/usr/java/jdk1.7.0_71/bin/j
Ava 100
RUN Update-alternatives--display Java
RUN java-version
EXPOSE 8080 9990
CMD ["/usr/jboss/bin/standalone.sh", "-C", "Standalone-full.xml", "-B", "0.0.0.0
"]

Build:

sudo docker build-t="javaee_docker_jboss" .

Build process:

Sending build context to Docker daemon 422.1 MB
Sending build context to Docker daemon
Step 0:from ubuntu:14.04
---> B39b81afc8ca
Step 1:maintainer admln <[email protected]>
---> Using cache
---> C6410B257ABC
Step 2:run Mkdir/usr/jboss
---> Running in faae0476fa09
---> bee1d5851e62
Removing intermediate container faae0476fa09
Step 3:copy wildfly-8.2.0.final/usr/jboss/
---> 8d40f390a11e
Removing intermediate container a7a4174c0e79
Step 4:copy javaeedocker.war/usr/jboss/standalone/deployments/
---> 1335bd7ad129
Removing intermediate container 589fa30b1311
Step 5:run mkdir/usr/java/
---> Running in AC21536064F7
---> cb4703bc284c
Removing intermediate container AC21536064F7
Step 6:copy jdk-7u71-linux-x64.tar.gz/usr/java/
---> 35a31c2bc140
Removing intermediate container f4c26050e511
Step 7:workdir/usr/java/
---> Running in 1217154d1cca
---> A17AF238FED9
Removing intermediate container 1217154d1cca
Step 8:run tar-zxf jdk-7u71-linux-x64.tar.gz
---> Running in dfb046ddb86d
---> ea154f6f3896
Removing intermediate container dfb046ddb86d
Step 9:run update-alternatives--install/usr/bin/javac Javac/usr/java/jdk1.7.0_71/bin/javac 100
---> Running in ff061540aae3
Update-alternatives:using/usr/java/jdk1.7.0_71/bin/javac to Provide/usr/bin/javac (javac) in Auto mode
---> c3f4118943cc
Removing intermediate container Ff061540aae3
Step 10:run update-alternatives--install/usr/bin/java Java/usr/java/jdk1.7.0_71/bin/java 100
---> Running in 764aa09ab43f
Update-alternatives:using/usr/java/jdk1.7.0_71/bin/java to Provide/usr/bin/java (Java) in Auto mode
---> fddc132f2010
Removing intermediate container 764aa09ab43f
Step 11:run update-alternatives--display java
---> Running in dd123440d778
Java-auto mode
Link currently points To/usr/java/jdk1.7.0_71/bin/java
/usr/java/jdk1.7.0_71/bin/java-priority 100
Current "Best" version is '/usr/java/jdk1.7.0_71/bin/java '.
---> 0951d9f62f99
Removing intermediate container dd123440d778
Step 12:run java-version
---> Running in 839afe5e2276
Java Version "1.7.0_71"
Java (TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot (TM) 64-bit Server VM (build 24.71-b01, Mixed mode)
---> f51af884a45f
Removing intermediate container 839afe5e2276
Step 13:expose 8080 9990
---> Running in ed736e99366e
---> Bce05a7bdb61
Removing intermediate container ed736e99366e
Step 14:cmd/usr/jboss/bin/standalone.sh-c standalone-full.xml-b 0.0.0.0
---> Running in fea176d2760b
---> 947def6b3995
Removing intermediate container fea176d2760b
Successfully built 947def6b3995

Start container

8180:8080 javaee_docker_jboss

Test:

Tomcat version:

Dockerfile:

#admln20150120From Ubuntu:14.04Maintainer admln<[email protected]>RUN mkdir/usr/tomcatcopy Apache-tomcat-7.0. $. tar.gz/usr/tomcat/Workdir/usr/tomcat/RUN tar zxf apache-tomcat-7.0. $. Tar.gzcopy Javaeedocker.war/usr/tomcat/apache-tomcat-7.0. $/webapps/RUN mkdir/usr/java/COPY JDK-7u71-linux-x64.tar.gz/usr/java/Workdir/usr/java/RUN Tar-ZXF jdk-7u71-linux-X64.tar.gzRUN Update-alternatives--install/usr/bin/javac Javac/usr/java/jdk1.7.0_71/bin/javac -RUN Update-alternatives--install/usr/bin/java Java/usr/java/jdk1.7.0_71/bin/Java -RUN Update-alternatives--Display Javarun Java-Versionexpose8080 9990CMD/usr/tomcat/apache-tomcat-7.0. $/bin/startup.sh && tail-f/usr/tomcat/Apache-tomcat-7.0. $/logs/catalina. out

Build start ...

Test:

Tomcat and JBoss are a bit different, and after JBoss starts, it's done by default, and the terminal runs out after Tomcat starts.

So I added a tail-f/usr/tomcat/apach in the CMD commande-tomcat-7.0.57/logs/catalina.out

Ensure that the terminal runs continuously.

Javaee&docker Container Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.