Getting windows docker directory mount on your container image



Let's say you want to use docker image as your development machine. So you would like to build a docker container and you like to mount a windows path so your changes can be persisted and directly reflected in your container.

Also if you see bloggers are saying you can run something like "docker exec it -v /app:/app" - well there are additional steps require, discussed below :-

So you have

Windows -->  Docker (Virtualbox) Your VM -> Container

Dev_Folder -> Map to VM Box as shared folder -> Mount it using docker -v command


Let's map your windows folder first (a shared folder in virtual box)

In your virtual box goto Settings -> Shared Folders ->



Please note :- this mapping is case sensitive, perhaps i should use all lowercase as a demo.

Next, if you open your docker default virtual machine, you should see "miacucinaCms" folder. All this happening before you run your container.

Setting up your container

To mount this "miacucinaCms" folder to your container image, you just have to

docker run -dit -p 5001:5001 -v /miacucinaCms:/app miacucinadev

Here, i am running my miacucinadev image (built long long time ago using dockerfile). You can see that i am trying to use -v option to mount "miacucinaCms" to container folder called /app.

Figure below clearly show that we can now browse code, edit and change code in windows and it will be reflected in our container.







Comments

Popular posts from this blog

A quick tutorial for OWASP ZAP tool for beginners

ionic2 cordova build android - Unable resolve gradle 2.2.3