When trying to pass data between a Docker container and the host, using ADD
in the Dockerfile might be sufficient at first. However, it’s one way, get burned in the image and so very inflexible.
The usual solution is to mount folders using docker
‘s -v
option. It’s simple, easy to use and pretty reliable. Just add -v "$(pwd):/root"
and the current folder will be mounted to the /root
folder in the container.
Using volumes is nice because they’re (can be) two way and (can) sync in real-time. Now you don’t need to rebuild your image every time you fix a typo. -v
has pretty deep configuration options too, in case you want to go down the rabbit hole.