Skip to content
Advertisement

Converting Shell Script to Dockerfile

I have Java app and want to generate docker image, I have shell script like this:

JavaScript

And I try to convert it into Dockerfile like this

JavaScript

It can be generated, but there’s an error when I try to run it like this:

JavaScript

I’ve also changed this script RUN for rJarFile in `ls ${APPLICATION_DIR}/lib/*.jar`; do export into this RUN for rJarFile in ls ${APPLICATION_DIR}/lib/*.jar; do export CLASSPATH=$rJarFile:$CLASSPATH; done, but none of them working. I don’t want to make Dockerfile execute the script. Below is logs when i generate and run it.

generating

Advertisement

Answer

You cannot update the classpath as you do with:

JavaScript

instead you can do

JavaScript

Also – please consider moving the script into a separate shell script and adding into the container. This would greatly simplify the Dockerfile, for example:

JavaScript

and keep your existing script inside start_java.sh

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement