Skip to content

Instantly share code, notes, and snippets.

@bdangit
Last active September 7, 2017 17:52
Show Gist options
  • Save bdangit/a265c5e0d3f4e5f0f84763341a0ac2fe to your computer and use it in GitHub Desktop.
Save bdangit/a265c5e0d3f4e5f0f84763341a0ac2fe to your computer and use it in GitHub Desktop.
Getting habitat to work on VMWare Workstation

Getting Habitat to work on VMware Workstation

When working with Docker-Toolbox on Win7 or even on Win10 (for those without Hyper-VM), you'll notice that docker dislikes any volume mounts that have any Windows paths. What you have to understand is that volume mounts work within the Linux VM that then get projected on to the Docker container. So this means the following:

  • NO to C:\\path\in\windows:/src
  • YES to /path/in/linux:/src where the /path/in/linux can be a Shared Drive to C:\\path\in\windows\ provided by VMWare.

By default, a docker-machine will have C:\Users shared and will exist as /c/Users inside the Linux VM. So if you want to volume mount your current working directory inside the container, you'll want to express it as:

# Assume working directory is C:\Users\bdangit\woof
docker run --volume /c/Users/bdangit/woof:/src someimage

If you want to use any other folder other than C:\Users, you'll need to add additional Shared Folders to your docker-machine VM which are provided below.

In the context of habitat, when you run this command: hab studio enter, it tries to volume mount C:\hab\cache\keys and C:\hab\cache\artifacts. If you translate these to what they must run as, they should be /c/hab/cache/keys and /c/hab/cache/artifacts, respectively. Of course if you ever look inside your docker-machine, ls /c/hab will not exist. So at a minimum you will want to add C:\hab as a Shared Folder.

To Add C:\hab as a Shared Folder

  1. On VMWare Workstation, locate the docker-machine. If you created a docker-machine called "dev", you should find a VM called "dev".
  2. Right click the machine and click Settings.
  3. Navigate to the Options tab and select the Shared Folders.
  4. Click Add.. and set the following parameters:
Host path: c:\hab
Name: hab
  1. Click Next.
  2. (Optional), if you need more now is the time to do it.
  3. Restart the VM.
  4. On command line, docker-machine ssh <docker-machine_name> sudo ln -s /mnt/hgfs/hab /c/hab
  5. (Optional), repeat the above command if you have more Shared Folders.
  6. Now you are ready to rock out hab studio with a huge caveat, you'll need to volume mount the right folders:
# example
docker run --rm --tty --interactive --privileged --volume /c/Users/bdangit/habtest:/src \
--volume /c/hab/cache/keys:/hab/cache/keys --volume /c/hab/cache/artifacts:/hab/cache/artifacts \
--volume /var/run/docker.sock:/var/run/docker.sock habitat-docker-registry.bintray.io/studio:0.30.2 enter

Future

  1. Provide an alias to do the above as a work-around
  2. Submit a PR to support both types of pathing in Win7/Win10withoutHyperVM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment