Mounting a Local Volume
Before we leave our docker-compose.yml, let’s make a small addition.
We’ve already seen how to mount a local directory inside a container with docker run by using the -v option—we did this in Generating a New Rails App Without Ruby Installed, so that the Rails project files generated inside the container would be available on our local machine.
A mounted local volume represents some filesystem that’s shared between your local machine and the container. Files in the mounted volume are synced both ways between your local filesystem and the container. Because of this, a local volume mount can allow us to develop locally and have the Rails server running in the container automatically pick up the file changes without restarting—just ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access