Build a docker java compiling environment, dockerjava

Source: Internet
Author: User

Build a docker java compiling environment, dockerjava
Build a java compiling environment using Dockerfile

1. includes the following software packages

  • Ubuntu
  • Jdk
  • Maven
  • Svn

2. jdk and maven must be downloaded manually.

  • Jdk-8u51-linux-x64.gz
  • Apache-maven-3.3.3-bin.tar.gz

3. Create a Dockerfile that contains the following content

FROM ubuntuRUN apt-get updateRUN apt-get -y install subversionADD jdk-8u51-linux-x64.gz /usr/localADD apache-maven-3.3.3-bin.tar.gz /usr/localENV JAVA_HOME /usr/local/jdk1.8.0_51ENV M2_HOME /usr/local/apache-maven-3.3.3ENV PATH $PATH:$JAVA_HOME/bin:$M2_HOME/bin

Simply put, it means to create an image based on ubuntu, update the software source, install svn, and then add the downloaded jdk and maven to the image, and put it in the/usr/local directory. Here I add a compressed package. The system will automatically decompress the package when building the image, and there will be no compressed files in the image, finally, set the environment variable.

4. Start building the image.

docker build -t dev .

After the build is complete, you can use docker images to see an image named dev, which we created, note that the Dockerfile file is in the same directory as the downloaded package, and you must ensure that the package is in the directory where the Dockerfile is located when running the preceding command.

5. Start

docker run -i -t dev

After the startup, enter java, mvn, and svn, and check whether all of them have been installed. Then, you can download the code from svn in the container and then package it through maven, then deploy it to the container containing tomcat.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.