I just realized the exit 0 may not be what you want. In my case it was fine until I wanted to run another command after the docker rm -f command. With || exit 0 the wrapper script exited, skipping the next step. Switching || exit 0 to || true keeps everything moving along.
I did something a little bit different.
What I did was to add a cleanup stage which would remove the docker container at the end of the build/test run.
You can probably specify that stage to run “when: always” to force it to remove the container regardless of build/test success or failure.