Create a new image or share source code in a volume in a docker container in development?
You should definitely make a new image instead of sharing the code via a mounted volume. Then whole docker ideology is to produce a self-contained "service", which can be portable across server (i.e. copy the image). Yuo docker file and image build process will track versions of your code, i.e. in your docker file you can pull a specific branch, or you can tag the image with a specific tag.
In case of a mounted volume, you never sure what version of your code is actually. run.
Hope this reason alone will help you to decide.
I'm wondering what would be the best practice to update the source code in a docker container that is run within( in JAVA and python). I could either modify my code, create a new image and run a container. In Java,  I would also need to compile the code. 
Another solution would be to just use a volume to share the code between my machine and the container so that each time I modify the behavior of my code I won't need to create a new docker image.
I'm asking all of this for development purposes, not deploying
Is there a best practice between these two solutions? What are the pros and cons? Is there a difference for a compiled language like a java compared to python?