Welcome to weblogs.com.pk Sign in | Join | Help

Docker on Windows: Customized Boot2Docker ISO with CIFS

Docker on Windows

When using Docker in Linux Virtual Machine on Windows (or Mac); especially in development environment; you definitely going to need “some way” to access data on the host OS system (source code / data of your application). Virtual Box has an ability to exposes the user home folder to the VMs and when you create a Boot2Docker VM using docker-machine it mounts the user home folder that you can access; but when using HyperV driver; sadly this is not the case as HyperV is bit more restrictive. The simplest way is to use Windows Shares; and if you have setup a NAT switch making it “Private” and sharing the required folder; you can access it from Linux / Boot2Docker VM. You will need to install cifs-utils

As per Wikipedia; Server Message Block (SMB), one version of which was also known as Common Internet File System (CIFS),operates as an application-layer network protocol mainly used for providing shared access to files, printers, and serial ports and miscellaneous communications between nodes on a network! Boot2Docker is based on Tiny Core Linux and it has notion of extensions that exists as tcz files and we load them using tce-load. For cifs-utils on Boot2Docker; we need to issue the following commands!

wget http://distro.ibiblio.org/tinycorelinux/5.x/x86/tcz/cifs-utils.tcz
tce-load -i cifs-utils.tcz

Once installed we can mount the shared folder from HyperV Host machine using mount; say for \\\src we will use following commands

sudo mkdir /mnt/srcshare
sudo mount -t cifs // /mnt/srcshare -o user=khurram,pass=password

Any extension we install on Tiny Core Linux gets lost across reboot; and given CIFS is often needed in development environment (especially if using HyperV as Virtualization platform) its better to create a Docker VM using “customized Boot2Docker ISO” Interestingly we can create a Docker Image to create such customized Boot2Docker ISO. Create a Dockerfile with this content

FROM boot2docker/boot2docker

#wget http://distro.ibiblio.org/tinycorelinux/5.x/x86/tcz/cifs-utils.tczRf
#tce-load -i cifs-utils.tcz

RUN echo "\nBoot2Docker with CIFS\n" >> $ROOTFS/etc/motd
RUN curl -L -o /tmp/cifs-utils.tcz $TCL_REPO_BASE/tcz/cifs-utils.tcz && \
unsquashfs -f -d $ROOTFS /tmp/cifs-utils.tcz && \
rm -rf /tmp/cifs-utils.tcz
RUN /make_iso.sh
CMD ["cat", "boot2docker.iso"]

To create an ISO; give these commands

docker build -t khurram/boot2docker:cifs –f YourAboveDockerFile .
docker run –rm khurram/boot2docker:cifs > boot2docker.cifs.iso

  • khurram/boot2docker:cifs is the tag name for Docker Image
  • docker build can take a considerable time; given it makes 2Gb+ image

And then to create a Docker VM using this customized ISO; use docker-machine

docker-machine create --driver hyperv --hyperv-virtual-switch NAT --hyperv-boot2docker-url boot2docker.cifs.iso Cifs

  • NAT is the name of HyperV Virtual Switch
  • Cifs is the name of HyperV VM


  • Note the presence of the MOTD we added in the VM; made with the customized Boot2Docker ISO

You can now easily mount the network shares in the Boot2Docker VM and then mount that host directory as a data volume in the docker container using docker run’s –v flag


Published Sunday, July 3, 2016 1:33 AM by khurram


No Comments

New Comments to this post are disabled