Configuring a dockerfile to 'read' from a directory? Configuring a dockerfile to 'read' from a directory? flask flask

Configuring a dockerfile to 'read' from a directory?


Instead of using COPY to move the code into the container, you'll use a "bind mount" (https://docs.docker.com/storage/bind-mounts/).

When you run the container, you'll do it with a command like this:

docker run --mount type=bind,source=<path_outside_container>,target=<path_inside_container> <image_tag>

For portability, I recommending putting this line in a script intended to be run from the repository root, and having the <path_outside_container> be "$(pwd)", so that it will work on other people's computers. You'll need to adjust <path_inside_container> and your CMD depending on where you want the code to live inside the container.

(Obviously you can also put whatever other options you'd like on the command, like --it --rm or -p <whatever>.)