Build a Java compilation environment with Dockerfile
1. Include the following packages
2, JDK, maven need to download manually, after downloading for
- Jdk-8u51-linux-x64.gz
- Apache-maven-3.3.3-bin.tar.gz
3. Create a Dockerfile file with 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 say the above meaning, is based on Ubuntu to create a mirror, then update the software source, then install SVN, and then add the downloaded JDK, maven to the image, and placed in the/usr/local directory, where I add a compressed package, in the construction of the image of the appropriate, The system will automatically unzip, and the image will not have compressed files, and then set the environment variable
4, finally start to build the mirror
docker build -t dev .
After the build, you can use Docker images to see an image called Dev, this is what we created, it is important to note that the Dockerfile file is in the same directory as the previously downloaded compressed package, Also make sure the directory where the Dockerfile is located when running the above packaging commands.
5. Start
docker run -i -t dev
After startup, the input Java, MVN, SVN, is not all installed, then you can in this container to download the code from SVN, and then through MAVEN packaging, and then deployed to the container containing Tomcat.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Building a Docker Java compilation environment