A pattern for updating dependencies in a Docker image

We use docker pretty heavily at work, and a pattern I’ve often run into is that I want to play around in a docker image to get something working, and then be able to “save” it back into the original image. This is generally a Python dependency or something similar that we’ve put into our requirements, but rebuilding all our dependencies takes a good bit of bandwidth and time.