Create a new image or share source code in a volume in a docker container in development?
You should make a new image, and if you think creating a new image and deploying is a task for you, than you can setup a CI/CD pipeline which will automatically compile java code, create a image and will deploy it for you whenever you push a code to GIT.
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?