Docker Docker Data Volumes Mounting a directory from the local host into a container

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

It is possible to mount a host directory to a specific path in your container using the -v or --volume command line option. The following example will mount /etc on the host to /mnt/etc in the container:

(on linux) docker run -v "/etc:/mnt/etc" alpine cat /mnt/etc/passwd
(on windows)  docker run -v "/c/etc:/mnt/etc" alpine cat /mnt/etc/passwd

The default access to the volume inside the container is read-write. To mount a volume read-only inside of a container, use the suffix :ro:

docker run -v "/etc:/mnt/etc:ro" alpine touch /mnt/etc/passwd


Got any Docker Question?