Sunday, 27 November 2016

Docker Toolbox on Windows: Mount any host directory (other than Users directory in c drive) as a data volume

This post is for you, if you are looking for mounting a host directory (which is not underneath the "C:\Users" folder) as a data volume in docker container using Docker Toolbox on Windows.

Problem Statement:


As per docker documentation --- "If you are using Docker Machine on Mac or Windows, your Docker Engine daemon has only limited access to your OS X or Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory. So, you can mount files or directories on OS X using".

This means, you can mount anything underneath "c:\Users" directory of host your Windows machine as a data volume in docker container seamlessly. For example, let's say you want to dump some data from "c:\Users\tirthalp\data" directory to "data" directory within Redis container in docker. Well, below just executing command will enable you to do it.

docker run -v /c/Users/tirthalp/.docker/data:/data --name <container-name> <image-name>


But, what is there is a need of mounting other folders (any folder which is not underneath "c:\Users" directory) of your Windows machine as a data volume in docker container? Well, that's not a piece of cake. For example, if you execute below command, the container would not complain. But actually mounting of folder in D drive as a data volume could not happen and data from your host Windows machine would not be accessible in docker container.

docker run -v /d/x-temp/data:/data --name <container-name> <image-name>


Solution:

I could not locate official docker documentation on this. After giving few tries, finally these steps worked --- add a shared folder to Docker Host VM and mount it as a data volume. Although the given steps are pretty clear, I thought to share screenshots of the same as following.

Step 1: Stop Docker Machine


Step 2: Add Shared Folder in Oracle VirtualBox Manager

Open Oracle VM VirtualBox Manager. Settings -> Shared Folder -> Add Share Folder (i.e. Tirthal-LABs).


Step 3: Permanently mount VirtualBox shared folder as a shared-data volume in Docker machine

Start docker machine.


SSH to docker machine, create directory in docker machine (i.e. /home/docker/tirthal-projects) and mount VirtualBox shared folder name (i.e. Tirthal-LABs) with it. This should enable you to access host Windows machine's data in docker machine @ /home/docker/tirthal-projects.


Try restarting docker machine. Now if you check at /home/docker/tirthal-projects, you would not see mounted host machine's data. For permanent mounting, add following two lines at the end of profile --- sudo vi /mnt/sda1/var/lib/boot2docker/profile

mkdir /home/docker/<directory-name>
sudo mount -t vboxsf -o uid=1000,gid=50 <virtual-box-shared-folder-name> /home/docker/<directory-name>


Try restarting docker machine again. Now if you check at /home/docker/tirthal-projects, you would not see mounted host machine's data.


Step 4: Mount a shared-storage volume as a data volume

Now you should be able to mount even other than "c:\Users" directories of host Windows machine in docker container as a data volume, if you have completed the above steps 1 to 3 successfully. For example, following command would mount "data" folder in container with a shared-storage "/home/docker/tirthal-projects/temp" on docker machine. Here, the "/home/docker/tirthal-projects" is mounted with the host Window machine's folder (i.e. D:\Tirthal-LABs\).

docker run -v /home/docker/tirthal-projects/temp:/data --name <container-name> <image-name>



References:


Sunday, 25 September 2016

Liferay Portal 7 - Getting Started Guide Series

I had written step by step post for LiferayPortal 6.2 - Getting Started Guide - Development Setup using Eclipse Kepler in past. Today, I thought to write series of posts for getting started with recently released Liferay Portal 7 CE, which has major changes with respect to introducing modular architecture and related development strategy.

If you are new to portal, then read what is portal? If you are new to Liferay, then read what is Liferay Portal (now broadly known as Liferay Digital Experience Platform)? But most of time, we don't understand all theoretical fundamentals until we have environment to try something practically. So first attempt can be to setup latest Liferay portal to try its few out-of-box features and functionalities. Then, further attempts can be setup Liferay IDE for creating hello world project and deploying to Liferay Portal.

Following series of posts may help you to get started with Liferay Portal 7 quickly, if you already have experience with Java development using Eclipse.
  1. Step by step guide to setup Liferay Portal
  2. Understanding Liferay Development Tooling options
  3. Basic setup of Liferay IDE
  4. Using Liferay IDE for Hello World Liferay MVC Portlet development and deployment

For now, enjoy these posts. I may add few more to the above list in future!

Also Refer
  • Liferay 7 Features from Developer Perspective
    • OSGi Support
    • Bootstrap 3.0 Look and Feel
    • Java 8 Support
    • Alloy Editor
    • Elastic Search
    • Support Integration Testing through Arquillian
    • Application Display Templates Support for Login, Language and Breadcrumb portlets.
    • Improvements in Web content management
    • Singe Page Application Development
    • Document Management storages extracted as modules      
    • Service Builder code now uses Declarative Services instead of Spring for dependency injection