Docker image to help deploying a springboot application on docker.
3.7K
Based on
openjdk:8u121-jre-alpine docker image.
This image is more that just a Spring Boot runner. I can launch any java command.
I created it first because I needed to launch a spring boot application in a container. But I didn't want to:
docker run command per environment.
docker run -name <myapp> -v <myappfolder>:/app -p 8080:8080 wattazoum/springboot-runnerThen access to http://localhost:8080 .
java commandThis is not the purpose of this image, but if needed, you can use
it to launch a java custom command.
$ docker run --rm -it wattazoum/springboot-runner -version
openjdk version "1.8.0_111-internal"
OpenJDK Runtime Environment (build 1.8.0_111-internal-alpine-r0-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)
Every command passed to the container will directly be fed to the java executable
inside the container.
Specificities of this image consist in:
springboot user (uid=1000)The container runs on a user called springboot
with the uid 1000. This allows every file created by the application to be used
by user uid=1000 on the docker host.
/appThe WORKDIR of the container. This folder might contain one and
only one jar/war, which is the springboot application jar.
Creating a /app/config/ directory will be automatically detected by Springboot
as the configuration folder. See SpringBoot documentation on externalizing configuration.
We also recommend the creation of the logs folder inside the /app folder.
The /app folder may also contain the setenv.sh file mentionned bellow.
Note: The /app folder seen in the container will usually be a storage mapped to an external resource (docker storage, host folder ...). So creating a subdirectory can be done externally.
Now if you want to play with the internal of the container, you can launch:
docker run -it --rm --entrypoint /bin/sh wattazoum/springboot-runnerYou can launch
/usr/local/bin/entrypoint.shto test the normal behavior of the container.
The defaut springboot http port is 8080. This port is exposed by the container.
So no need to change it in your configuration.
setenv.sh fileThis file allows you to set options to be passes to the java command.
The resulting command will be in the form of :
java $JAVA_OPTS -jar my_detected_jar $APP_ARGS
The following options are available (both optional):
-Xmx1g-Dfile.encoding=utf8Here is an exemple of content:
JAVA_OPTS="-Xmx1g -Dfile.encoding=utf8"
APP_ARGS="--loglevel=debug"
Note: The content of the file can be more complex than the sample above. It will be interpreted by
/bin/shso all of the DASH syntax is supported
Content type
Image
Digest
Size
64.6 MB
Last updated
over 8 years ago
docker pull wattazoum/springboot-runner