Ever tried to work on an old project that requires that you install on old version of java. Say java 5. On a Mac… You know this nightmare that no windows user will ever face:
An easy way to do that is to boot a linux/windows vm. An easier way is to use Docker.
Here’s the Dockerfile that creates a container with java6 inside. You can then use the container to build a maven project.
FROM ubuntu:12.04 MAINTAINER David Gageot # Install java 6 RUN apt-get update RUN apt-get install -y openjdk-6-jdk # Install tools RUN apt-get install -y maven # Define mountable directories. VOLUME ["/dir"] # Define working directory. WORKDIR /dir # Define default command. CMD ["java"]
Build the container with docker build -t dgageot/java6 . Run the container with docker run -t dgageot/java6 java or docker run -t dgageot/java6 mvn
You can map a folder on your host to the /dir folder on docker so that the java inside the container is used to build the project outside the container.