Answering because there's some misinformation in other answers here. The correct answer is in the comment from MyTwoCents:
It will behave same way as it would when you do it on your system. So if you edit nano my_python_script.py will it do change automatically on your system?
Put quite simply, if your application dynamically updates itself when the files on the filesystem change, then the same will happen when you modify those files inside of a container.
The misinformation in Mark's answer concerns me:
Docker container is immutable, so whatever changes you do in filesystem of the container itself won't survive the restart of container
That is not accurate. Docker images are stored as a collection of filesystem layers that are immutable. Containers are ephemeral, files changed inside the container will revert when the container is deleted and replaced with a new container. However, restarting a container effectily stops and restarts the process inside the container with the same filesystem state of that container. Any changes that happen to the container's filesystem are maintained for the life of the container. Volumes are used when you want changes to survive beyond the life of a single container.
The correct answer is that you most likely need to restart the python process inside the container to see the filesystem changes, and stopping the python process will stop the container. It becomes an awkward process to keep exec
'ing into a container to make changes and then exit to restart the container for the changes to appear. Therefore, a more typical developer workflow is to mount the filesystem of code into the container so you can make changes directly on your host, where those changes will not be logs, and then restart the container. Since python does not require compiling your code into a binary, you'll see your changes on every restart. If your Dockerfile contained lines like:
FROM python
COPY . /code
CMD python /code/my_python_script.py
You could make that a volume with:
docker run --name container_name -v "$(pwd):/code" image_name
And then to restart with changes:
docker restart container_name