When using docker run, the --mount parameter allows you to specify a directory to recreate within the Docker container so that you can edit your code locally and then run it within the Docker container without rebuilding the image.

Consider whether coding within a running container fits your use case better.

Example#

docker run -it --mount type=bind,source="$(pwd)/tests",target=/tests image_tag

This uses the tests directory within the working directory as the source and puts the contents within a directory /tests in the container whenever you call docker run.

Source#

You Don’t Need to Rebuild Your Development Docker Image on Every Code Change Bind mounts - Docker documentation