Overview

Host folders are directories on the host which are shared between the host and the Minishift VM. This allows for two way file synchronization between the host and the VM. The following sections discuss usage of the minishift hostfolder command.

The minishift hostfolder Command

Minishift provides the minishift hostfolder command to list, add, mount, unmount and remove host folders. You can use the hostfolder command to mount multiple shared folders onto custom specified mount points.

Currently only CIFS is supported as a host folder type. Support for SSHFS-based host folders is in progress, as described in GitHub issue #317. If you want to manually set up SSHFS, see SSHFS Host Folders.

Prerequisites

To use the minishift hostfolder command, you need to be able to share directories using CIFS. On Windows, CIFS is the default technology for sharing directories. For example, on Windows 10 the C:\Users directory is shared by default and can be accessed by locally-authenticated users.

It is also possible to use CIFS on macOS and Linux. On macOS, you can enable CIFS-based shares under System Preferences > Sharing. See How to connect with File Sharing on your Mac for detailed setup instructions.

On Linux, follow your distribution-specific instructions to install Samba.

Displaying Host Folders

The minishift hostfolder list command gives you an overview of the defined host folders, their names, mount points, remote paths and whether they are currently mounted.

An example output could look like:

$ minishift hostfolder list
Name        Mountpoint            Remote path              Mounted
myshare     /mnt/sda1/myshare     //192.168.1.82/MYSHARE   N

In this example, there is a host folder with the name myshare which mounts //192.168.1.82/MYSHARE onto /mnt/sda1/myshare in the Minishift VM. The share is currently not mounted.

The remote path must be reachable from within the VM. In the example above, 192.168.1.82 is the IP of the host within the LAN, which is one option you can use. You can use ifconfig (or Get-NetIPAddress | Format-Table on Windows) to determine a routable IP address.

Adding Host Folders

The minishift hostfolder add command allows you to define a new host folder. This is an interactive process that queries the relevant details for a host folder based on CIFS.

Adding a CIFS based hostfolder
$ minishift hostfolder add myshare (1)
UNC path: //192.168.99.1/MYSHARE   (2)
Mountpoint [/mnt/sda1/myshare]:    (3)
Username: john                     (4)
Password: [HIDDEN]                 (5)
Domain:                            (6)
Added: myshare
1 (Required) Actual minishift hostfolder add command that specifies a host folder with the name of myshare.
2 (Required) The UNC path for the share.
3 The mount point within the VM. The default is /mnt/sda1/<host folder name>.
4 (Required) The user name for the CIFS share.
5 (Required) The password for the CIFS share.
6 The domain of the share. Often this can be left blank, but for example on Windows, when your account is linked to a Microsoft account, you must use the Microsoft account email address as user name as well as your machine name as displayed by $env:COMPUTERNAME as a domain.

On Windows hosts, the minishift hostfolder add command also provides a users-share option. When this option is specified, no UNC path needs to be specified and C:\Users is assumed.

When you use the Boot2Docker ISO with the VirtualBox driver, VirtualBox guest additions are automatically enabled and occupy the /Users mount point.

Instance-Specific Host Folders

By default, host folder definitions are persistent, similar to other persistent configuration options. This means that these host folder definitions will survive the deletion and subsequent re-creation of a Minishift VM.

In some cases you might want to define a host folder just for a specific Minishift instance. To do so, you can use the --instance-only flag of the minishift hostfolder add command. Host folder definitions that are created with the --instance-only flag will be removed together with any other instance-specific state during minishift delete.

Mounting Host Folders

After you add host folders, you use the minishift hostfolder mount command to mount a host folder by its name:

$ minishift hostfolder mount myshare
Mounting 'myshare': '//192.168.99.1/MYSHARE' as '/mnt/sda1/myshare' ... OK

You can verify that the host folder is mounted by running:

$ minishift hostfolder list
Name       Mountpoint          Remote path              Mounted
myshare    /mnt/sda1/myshare   //192.168.99.1/MYSHARE   Y

Alternatively, you can list the actual content of the mounted host folder:

$ minishift ssh "ls -al /mnt/sda1/myshare"

Auto-Mounting Host Folders

Host folders can also be mounted automatically each time you run minishift start. To set auto-mounting, you need to set the hostfolders-automount option in the Minishift configuration file.

$ minishift config set hostfolders-automount true

After the hostfolders-automount option is set, Minishift will attempt to mount all defined host folders during minishift start.

Unmounting Host Folders

You use the minishift hostfolder umount command to unmount a host folder.

$ minishift hostfolder umount myshare
Unmounting 'myshare' ... OK

$ minishift hostfolder list
Name       Mountpoint          Remote path              Mounted
myshare    /mnt/sda1/myshare   //192.168.99.1/MYSHARE   N

Deleting Host Folders

You use the minishift hostfolder remove command to remove a host folder definition.

$ minishift hostfolder list
Name        Mountpoint            Remote path              Mounted
myshare     /mnt/sda1/myshare     //192.168.1.82/MYSHARE   N

$ minishift hostfolder remove myshare
Removed: myshare

$ minishift hostfolder list
No host folders defined

SSHFS Host Folders

This host folder type is not supported by the minishift hostfolder command and requires manual configuration.

You can use SSHFS-based host folders if you have an SSH daemon running on your host. Normally, this prerequisite is met by default on Linux and macOS.

Most Linux distributions have an SSH daemon installed. If not, follow the instructions for your specific distribution to install an SSH daemon.

macOS also has a built-in SSH server. To use it, make sure that Remote Login is enabled in System Preferences > Sharing.

On Windows, you can install OpenSSH for Windows.

The following steps demonstrate how to mount host folders with SSHFS.

  1. Run ifconfig (or Get-NetIPAddress on Windows) to determine the local IP address from the same network segment as your Minishift instance.

  2. Create a mountpoint and mount the shared folder.

    $ minishift ssh "sudo mkdir -p /Users/<username>"
    $ minishift ssh "sudo chown -R docker /Users"
    $ minishift ssh
    $ sshfs <username>@<IP>:/Users/<username>/ /Users
  3. Verify the share mount.

    $ minishift ssh "ls -al /Users/<username>"