Build a docker java compiling environment, dockerjava
Build a java compiling environment using Dockerfile
1. includes the following software packages
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.