Clean up on Docker shutdown

There may be times that you’d need to clean up resources such as temporary files or in my case deregister a container from a WebSphere Liberty Collective. To set this up, we just need to use `trap` on `bash` to handle any cleanup. This will also work with `docker-compose.yml` built stacks and `replica`s.

The skeleton of the start up script (e.g. ``) would be as follows


cleanupFunction() {
trap cleanupFunction 0

myNormalDaemonProcess &


`DockerFile` just needs to `COPY` the script and set it as the `CMD`. There is no need for an `ENTRYPOINT` nor use `tini` nor use `–init`. Simply

CMD "/"