From this post I found out that I can detach from a docker container with the sequence Ctrl+p + Ctrl+q.
I was wondering, is it possible to create a single bash (or python, or whatever) script that enters a docker container, runs a few commands, then uses the escape sequence to exit the container? I think it may not be possible, but please confirm/deny this!