Well, Docker on MS-Window is a chore!

It’s all a bit of a hack, so here are some notes to help you along.

Editing files in MS-Windows to run in Docker.

Docker uses a Linux vm within Oracle’s Virtualbox. It is normally called ‘default’. Therefore the configuration files and the program files (python etc.) are actually read and run within Linux in this virtual machine. No, Docker is not virtualizing MS-Windows!

There is an encoding difference between a Dos-based file and a Linux-based file. Dos-based files are ANSI with end-of-line markers of a CR+LF (carriage return or control-M – ^M and Line Feed)  where Linux files are UTF-8 and use LF.

This problem shows up with a docker build or run failing with an error in a script showing a ^M in the error message.

It can further be seen using the cat command at the Docker Quickstart prompt:

cat -A cmd.sh

and fixed with the dos2unix command:

dos2unix cmd.sh

 

Working Project not on the C Drive.

It is not unknown to have a seperate drive (D for example) to store your documents and projects. In this case, Docker will ignore this drive and not find various config and script files. Docker expects the files to be in the primary path of C:/Users/Your-Name/.

This is fixed by adding an extra directory share in Virtualbox and then mounting it within the Docker image.

First, add the extra share within the Shared Folders section of the VM within Virtualbox e.g. Name: d Path: D:/

Then within the default Docker vm, add a mount command that will be executed on each boot:

Edit file /var/lib/boot2docker/profile and add to the end:

mkdir /d
mount -t vboxsf -o uid=1000,gid=50 d /d

The “d” and “/d” should match the shared folder within the Virtualbox configuration.

See https://github.com/boot2docker/boot2docker for more information.

After starting the Docker Quickstart change to your working directory/folder using the mount name:

cd /d/Projects/docker-web-server/