Mount local volumes in your Windows and Linux containers

Docker containers
Photo by Guillaume Bolduc on Unsplash

Many of the organizations now use containerization technologies to rapidly deliver software. Gone are those days, when a developer had to setup and configure the entire product on a specifically compatible version of operating system with bunch of other per-requisites. Containerization has definitely gained pace over the year and so has Docker, a name so synonymous to containers. No not the containers found in dockyards :)

If you are familiar to using container, then at some point in time, you definitely had to use mounted volumes/drives in your running image container. So let’s jump into how you can mount volume in your container

The docker command to mount volumes in windows or linux image containers is more or less the same with subtle differences.

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

While running the container we just need to specify the volume flag and the binding local-machine-path:container-path


docker run -v /home/user/mount:/usr/share/nginx/html nginx:latest
Mount volume on docker Linux

On windows, in a similar fashion we can mount the local volume however notice the highlighted syntax for path bindings which is somewhat different than regular windows styled path

Folder to be mounted
Mount volume on docker Windows

This is how we can use local volumes to perform some of the daily tasks during development using containers. However, for production usages an orchestrator like Kubernetes, swarm etc. will use persistent volume claims to assign storage as per requirement and abstracts away the need to know underlying storage infrastructure, that could be NFS or a cloud-provider-specific storage system. More on that in upcoming articles. Thanks for reading!

Software developer