How can I make the docker container to run a script every time when the container restart?

I know I can use the dockerfile’s CMD RUN and ENTRYPOINT command to run a script when the container initiate, but how can I make the container to run a script every time when the container restart on failure?

Source: StackOverflow