Is it possible to run Gretty projects in Docker Gradle container?
Normally the Gretty task tomcatRun
starts Tomcat app server and you can browse the app at http://localhost:8080/app-name. With Docker Gradle image the task is successfully started but the container is terminated immediately after that.
Steps for reproducing the issue:
cd hello_gretty
docker run --rm -u gradle -v "$PWD":/home/gradle/project -w /home/gradle/project gradle gradle wrapper
tomcatRun
: ./gradlew tomcatRun
tomcatRun
with Gradle Docker image:
docker run --rm -u gradle -p 8080:8080 -v "$PWD":/home/gradle/project -w /home/gradle/project gradle gradle tomcatRun
tomcatRun
is started (takes some time) but for some reason the
container terminates immediately after that. Maybe the task was completed
without pressing any key.I also created a Docker issue about the problem.
Adding -t
or --tty
to docker
command keeps Tomcat running. Also add -i
or --interactive
if you want to stop Tomcat with "any key" as Gretty says: "Press any key to stop the server."
docker run --rm -u gradle -it -p 8080:8080 -v "$PWD":/home/gradle/project -w /home/gradle/project gradle gradle tomcatRun
Thank you David Maze for helping.