How To Use DockerFile To Create A Volume With Windows Containers

In this blog post, I’ll show you how to create a volume and mount it Into a Windows Container using Docker.

Mounting Images In Containers Is very Important because It gives the ability to copy, store and backup data from and to running containers.

Containers are not designed to store or keep data Inside them so It’s Very Important to make sure that Important data Is stored outside the Container.

In the past I’ve blogged about copying data to Windows Containers, This article will add another method.

DockerFile

In the example below, I have a very simple DockerFile with that will build an Image using Nano Server.

In the second line, I’m using the VOLUME command to create a Volume on the container host In the following page c:\programdata\docker\volumes

Below, I’ll use the docker build command to build the Image

docker build -t volume .

Once done, I’ll create a new Container from the Image

docker run --rm -it --name web001 volume:latest powershell

At the same time, docker will create the folder with the Container’s name Inside the Volume folder.

Below, you can see the volume I created In the DockerFile (Called data) and I’ll go ahead and create a file inside it.

And as you can see below, the file was created on the Container Host and not Inside the Container

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.