I want to create docker file with conditional statements. i get parameters from outside ( BUILD_TOOL) . This is the code but i got error while building docker image.
i got this error = dockerfile parse error line 23: unknown instruction: ELSE
RUN if [ "$BUILD_TOOL" = "maven" ] ; then
RUN mvn clean install;
#if build tool is gradle
else
RUN gradle clean;
fi
Dokerfile itself does not have conditional statements. However you can implement them in shell:
RUN if [ "$BUILD_TOOL" = "maven" ] ; then \
echo do something; \
else \
echo do something else; \
fi
Just remember to add \
at the end of each line when you have a multi-line command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With