Accessing files from Docker container in Finder

I'm exploring using Docker for web development on my MacBook. I've set up a couple of containers successfully, but one thing has me completely lost. How do I make the web files accessible through the Finder so can edit in BBEdit & upload to shared hosting?

In case it's relevant, I'm using a 2017 MacBook running Big Sur.


Solution 1:

Mount a volume in the container from a folder on the host.

docker run -v /path/on/host:/path/in/container …

https://docs.docker.com/engine/reference/run/#volume-shared-filesystems

The path on the host will be visible in Finder and changes made in one will be reflected in the other.