Docker image remove while rebuilding app

You could try running them in series in a bash script?

I already created a custom bash script for rebuilding the app and after rebuilding done then removed unused docker images from a discourse docker container

However, I’m interested in knowing whether these commands can be added to the app.yml file or the launcher file.

I experimented with them on the staging site once but encountered an issue in the launcher file. While the commands work for me, using them results in the removal of all images.
docker image prune -a --force

To address this, I incorporated a filter for the last 24 hours in the command:
docker image prune -a --force --filter "until=240h" and this solution is effective for me.