Stranice

Friday 28 August 2015

Working with directories in Docker using Windows 7 x64

This example was performed by using Docker Windows CLI 1.8.1

I will use linux shell on Windows.
The easiest way to run a shell is by installing Git with Unix tools.

Mounting directories from Windows host to Docker

 We need to put our directories into c:\Users\ directory. 
 docs: https://docs.docker.com/userguide/dockervolumes/ 
(Mount a host directory as a data volume)

There is a slight change when working in shell that worked in my case is that extra / need to be put.
So the following command mounts a directory from a host 

docker run -v //c/Users/directory:/directory image-name command

note: the volume is mounted temporary, you need to copy is into other directory,
or you can use docker cp command to copy data from host to container

Running docker with working working directory

We have the same problem as when  mounting directory.
That means we need to add extra / to run a directory from the container.
If don't do it a directory from host machine will be demanded.

This is example for first level directory in docker image

docker run -d -w //directory docker-image command


For initial startup with docker toolbox in Windows 7
Docker-machine on Windows 7 x64 




No comments:

Post a Comment