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 CIFS and SSHFS based host folders are supported.

SSHFS based host folders are not working with the minikube ISO for now, because it is missing the sshfs dependency. This will be addressed in a future release of the minikube ISO.

Prerequisites

SSHFS

SSHFS is the default technology for sharing host folders. It works without any prerequisite.

CIFS

Host folders can be shared using CIFS. It is possible to use CIFS on Windows, 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    Type    Source               Mountpoint       Mounted
test    sshfs   /Users/john/test     /mnt/sda1/test   N

In this example, there is a sshfs based host folder with the name test which mounts /Users/john/test onto /mnt/sda1/test in the Minishift VM. The share is currently not mounted.

Adding Host Folders

The minishift hostfolder add command allows you to define a new host folder.

The exact syntax to use depends on the host folder type. Independent of the type you can choose between non-interactive and interactive configuration. The default it non-interactive. By specifying the --interactive you can select the interactive configuration mode.

The following sections give examples for configuring CIFS and SSHFS host folders.

CIFS

Adding a CIFS based hostfolder
$ minishift hostfolder add -t cifs --source //192.168.99.1/MYSHARE --target /mnt/sda1/myshare --options username=john,password=mysecret,domain=MYDOMAIN myshare

The above command will create a new host folder with the name of myshare. The source of the host folder is the UNC path //192.168.99.1/MYSHARE which is required. The target or mount point is /mnt/sda1/myshare within the Minishift VM. Using the --options flag host folder type specific options can be specified using a list of comma separated key/value pairs. In the case of a CIFS host folder the required options are the user name for the CIFS share as well as the password. Via the the --options flag the domain of the share can be specified as well. Often this can be left out, 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.

SSHFS

Adding an SSHFS based hostfolder
$ minishift hostfolder add -t sshfs --source /Users/john/myshare --target /mnt/sda1/myshare myshare

For the case of a SSHFS based host folder only the source and target of the host folder need to be specified.

When adding hostfolders, one can give type specific options to be used while mounting by using the --options flag, for example:

$ minishift hostfolder add -t sshfs --source ~/myshare/ --target /mnt/sda1/myshare --options "-o compression=no" myshare

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 have added host folders, you use the minishift hostfolder mount command to mount a host folder by its name:

$ minishift hostfolder mount myshare

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"

When mounting SSHFS based host folders a SFTP server process is started on port 2022 of the host. Make sure that your network and firewall settings allow this port to be opened. If you need to configure this port you can make use of Minishift’s persistent configuration using the key hostfolders-sftp-port, for example:

$ minishift config set hostfolders-sftp-port 2222

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

$ 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

$ minishift hostfolder list
No host folders defined