Gracefully stop Phusion Passenger running on apache

I have a docker container with apache running in foreground. On stopping the docker container , a SIGTERM is sent to all the child processes , which is apache in our case.

Now, the problem i am facing is to gracefully shutdown apache on receiving SIGTERM signal.
Apache normally terminates on the current requests immediately which is the main cause of the problem . Somehow, i need to translate the SIGTERM signal to SIGWINCH , which would eventually gracefully shutdown the server.

  • Docker Build Error
  • Does virtualenv serve a purpose (in production) when using docker?
  • how to configure sensu keepalive to throw an alert to slack
  • Docker inter-container routing
  • RabbitMQ cluster by docker-compose on different hosts and different projects
  • Jhipster CI (Jenkins 2 + Sonarqube) -> Memory Heap
  • I was thinking of writing some kind of wrapper script , but couldn’t get as to how to start.

    Any suggestions in this regard would be highly appreciated!


  • What docker image use for ionic CD / e2e testing? Ubuntu or just node?
  • Mongodb won't start in Docker container when remote-mounting a volume from host
  • Is it correct to attach code through volume in kubernetes?
  • Running multiple docker instances in EC2
  • How do I get the address of the host when using 'docker build'?
  • Unable to run Openfire with supervisord in docker container
  • One Solution collect form web for “Gracefully stop Phusion Passenger running on apache”

    The tomcat inside of container can be stopped gracefully by issuing below command (change tomcat path if needed):

    docker exec -it <container id / name> /usr/local/apache2/bin/apachectl -k graceful

    And to your comment, if you want to see the tomcat log in case if it is not running in foreground

    docker exec -it <container id / name> tail -f tail -f /usr/local/apache2/logs/error_log

    UPDATE: Based on the comments.

    From the docker documentation, you may specify the time while stopping the docker container. By default, it will only wait for 10 sec.

    To stop container with different timeout:

    docker stop -t <time in seconds> <container id/ name>

    I believe that, increasing time out while stopping might help in your case.

    UPDATE2 sending custom signal, SIGWINCH in your case. Please refer here for more details.

    docker kill -s SIGWINCH <apache container id / name>

    There are helpful resources on signal trapping:

    Hope these are helpful.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.