1

I would like when running a docker container with a Java application (spring or legacy applications), when finishes tomcat startup, run a script that plays a sound (which would serve as a notification).

The problem is know how run commands triggered after Tomcat startup.

diegoqueres
  • 149
  • 1
  • 13
  • As a general rule, "plays a sound" or otherwise interacting with the host's hardware devices isn't something you can do from a container. You might try one of the techniques in [Docker Compose wait for container X before starting Y](https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y) (the approaches using `nc` or `wait-for-it` aren't Docker-specific) to run this from the host. – David Maze Sep 27 '20 at 19:30

1 Answers1

0

You can have a script waiting for Tomcat to be fully ready

until [ 
  "$(curl -w '%{response_code}' --no-keepalive -o /dev/null --connect-timeout 1 
          -u USERNAME:PASSWORD http://localhost:8080/manager/text/list)" == "200"];

So your Dockerfile ENTRYPOINT could be launching catalina.sh && yourScript.

Or, as in here, launching your script with nohup command before calling catalina.sh.

The idea remain: your script will loop until it detects Tomcat is ready.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250