Dockerfile ONBUILD instruction
I read on the docker documentation how ONBUILD instruction can be used, but it is not clear at all.
Can someone please explain it to me?
One Solution collect form web for “Dockerfile ONBUILD instruction”
The ONBUILD intruction is very useful for automating the build of your chosen software stack.
The Maven container is designed to compile java programs. Magically all your project’s Dockerfile needs to do is reference the base container containing the ONBUILD intructions:
FROM maven:3.3-jdk-8-onbuild CMD ["java","-jar","/usr/src/app/target/demo-1.0-SNAPSHOT-jar-with-dependencies.jar"]
The base image’s Dockerfile tells all
FROM maven:3-jdk-8 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app ONBUILD ADD . /usr/src/app ONBUILD RUN mvn install
There’s a base image that has both Java and Maven installed and a series of instructions to copy files and run Maven.
The following answer gives a Java example
- How to build a docker container for a java app