Persisting data in docker context
Mounted volumes can be used to preserve state between runs, apart from that Docker is stateless by design. To make a local directory available inside the Docker container, you can use the -v option, for example:

docker run -v /path/to/local/dir/:/mountpath/inside/docker ...

But if I understand your question correctly, you are asking for a faster feedback cycle while working on the Dockerfile. For that, I would recommend to start the container, and attach an interactive shell to try out your changes. Once you made some progress, update the Dockerfile.

$ docker ps
CONTAINER ID  IMAGE        COMMAND  CREATED           STATUS        PORTS  NAMES
f1217635695d  ubuntu:18.04 "bash"   23 seconds ago   Up 21 seconds         stoic_austin

$ docker exec -it f1217635695d bash
root@f1217635695d:/# ...


Also note that proper use of caching can speed up rebuilds of the Docker container after changes significantly.


  (from your question)
  1. Kill the container and prune it out of the system.


Pruning should not be necessary unless you run out of disk space. It should be sufficient to update the tag, for example:

docker build -t test .
docker run --rm -it test


test:latest will point to the last image id that was created. docker images will show that the previous images are not deleted, but as said, if you have enough disk space available, it is not a big concern.