I took @Dmitriusan's answer and made it into an alias:
alias docker-run-prev-container='prev_container_id="$(docker ps -aq | head -n1)" && docker commit "$prev_container_id" "prev_container/$prev_container_id" && docker run -it --entrypoint=bash "prev_container/$prev_container_id"'
Add this into your ~/.bashrc
aliases file, and you'll have a nifty new docker-run-prev-container
alias which'll drop you into a shell in the previous container.
Helpful for debugging failed docker build
s.