Basic Usage

Overview

When you use Minishift, you interact with the following components:

  • the Minishift virtual machine (VM)

  • the Docker daemon running on the VM

  • the OpenShift cluster running on the Docker daemon

The Minishift architecture diagram outlines these components. The minishift binary, placed on the PATH for easy execution, is used to start, stop and delete the Minishift VM. The VM itself is bootstrapped off of a pluggable, live ISO image.

Some Minishift commands, for example docker-env, interact with the Docker daemon, whilst others communicate with the OpenShift cluster, for example the openshift command.

Once the OpenShift cluster is up and running, you interact with it using the oc binary. Minishift caches this binary under $MINISHIFT_HOME (per default ~/.minishift). minishift oc-env is an easy way to add the oc binary to your PATH.

For more details about using Minishift to manage your local OpenShift cluster, see the Interacting with OpenShift section.

Minishift architecture

Figure 1. : Minishift architecture

Minishift Life-cycle

Minishift start Command

The minishift start command creates and configures the Minishift VM and provisions a local, single-node OpenShift cluster within the Minishift VM.

The command also copies the oc binary to your host so that you can interact with OpenShift through the oc command line tool or through the Web console, which can be accessed through the URL provided in the output of the minishift start command.

Minishift stop Command

The minishift stop command stops your OpenShift cluster and shuts down the Minishift VM, but preserves the OpenShift cluster state.

Starting Minishift again will restore the OpenShift cluster, allowing you to continue working from the last session. However, you must enter the same parameters that you used in the original start command.

Minishift delete Command

The minishift delete command deletes the OpenShift cluster, and also shuts down and deletes the Minishift VM. No data or state are preserved.

Runtime Options

The runtime behavior of Minishift can be controlled through flags, environment variables, and persistent configuration options.

The following precedence order is applied to control the behavior of Minishift. Each action in the following list takes precedence over the action below it:

  1. Use command line flags as specified in the Flags section.

  2. Set environment variables as described in the Environment Variables section.

  3. Use persistent configuration options as described in the Persistent Configuration section.

  4. Accept the default value as defined by Minishift.

Flags

You can use command line flags with Minishift to specify options and direct its behavior. This has the highest precedence. Almost all commands have flags, although different commands might have different flags. Some of the commonly-used command line flags of the minishift start command are cpus, memory or vm-driver.

Environment Variables

Minishift allows you to specify command line flags you commonly use through environment variables. To do so, apply the following rules to the flag you want to set as an environment variable.

  1. Apply MINISHIFT_ as a prefix to the flag you want to set as an environment variable. For example, the vm-driver flag of the minishift start command becomes MINISHIFT_vm-driver.

  2. Use uppercase characters for the flag, so MINISHIFT_vm-driver in the above example becomes MINISHIFT_VM-DRIVER.

  3. Replace - with _, so MINISHIFT_VM-DRIVER becomes MINISHIFT_VM_DRIVER.

Environment variables can be used to replace any option of any Minishift command. A common example is the URL of the ISO to be used. Usually, you specify it with the iso-url flag of the minishift start command. Applying the above rules, you can also specify this URL by setting the environment variable as MINISHIFT_ISO_URL.

You can also use the MINISHIFT_HOME environment variable, to choose a different home directory for Minishift. By default, Minishift places all runtime state into ~/.minishift. This environment variable is currently experimental and semantics might change in future releases.

Persistent Configuration

Using persistent configuration allows you to control Minishift behavior without specifying actual command line flags, similar to the way you use environment variables. You can also define global configuration using --global flag. Global configuration is applicable to all profiles.

Minishift maintains a configuration file in $MINISHIFT_HOME/config/config.json. This file can be used to set commonly-used command line flags persistently for individual profiles. The global configuration file is maintained at $MINISHIFT_HOME/config/global.json.

Persistent configuration can only be applied to the set of supported configuration options that are listed in the synopsis of the minishift config sub-command. This is different from environment variables, which can be used to replace any option of any command.

By Default minishift persist start flags to persistent configuration, to disable it, use minishift config set save-start-flags false.

Setting Persistent Configuration Values

The easiest way to change a persistent configuration option is with the minishift config set sub-command. For example:

  1. # Set default memory 4096 MB
  2. $ minishift config set memory 4096

The easiest way to set a persistent configuration option across all profiles is with the minishift config set --global sub-command.

For example, you can set the default memory to 8192 MB for every profile as follows:

  1. $ minishift config set --global memory 8192

Flags which can be used multiple times per command invocation, like docker-env or insecure-registry, need to be comma-separated when used with the config set command. For example, from the CLI, you can use insecure-registry like this:

  1. $ minishift start --insecure-registry hub.foo.com --insecure-registry hub.bar.com

If you want to configure the same registries in the persistent configuration, you would run:

  1. $ minishift config set insecure-registry hub.foo.com,hub.bar.com

To view all persistent configuration values, you can use the minishift config view sub-command:

  1. $ minishift config view
  2. - memory: 4096

To view all persistent configuration values in the global configuration file, you can use the minishift config view --global sub-command:

  1. $ minishift config view --global
  2. - memory: 8192

Alternatively, you can display a single value with the minishift config get sub-command:

  1. $ minishift config get memory
  2. 4096

Unsetting Persistent Configuration Values

To remove a persistent configuration option, you can use the minishift config unset sub-command. For example:

  1. $ minishift config unset memory

The precedence for user-defined values is as follows:

  1. Command line flags.

  2. Environment variable.

  3. Instance-specific configuration.

  4. Global configuration.

Persistent Volumes

As part of the OpenShift cluster provisioning, 100 persistent volumes are created for your OpenShift cluster. This allows applications to make persistent volumes claims. The location of the persistent data is determined in the host-pv-dir flag of the minishift start command and defaults to /var/lib/minishift/openshift.local.pv on the Minishift VM.

HTTP/HTTPS Proxies

If you are behind an HTTP/HTTPS proxy, you need to supply proxy options to allow Docker and OpenShift to work properly. To do this, pass the required flags during minishift start.

For example:

  1. $ minishift start --http-proxy http://YOURPROXY:PORT --https-proxy https://YOURPROXY:PORT

In an authenticated proxy environment, the proxy_user and proxy_password must be a part of proxy URI.

  1. $ minishift start --http-proxy http://<proxy_username>:<proxy_password>@YOURPROXY:PORT \
  2. --https-proxy https://<proxy_username>:<proxy_password>@YOURPROXY:PORT

You can also use the --no-proxy flag to specify a comma-separated list of hosts that should not be proxied.

Using the proxy options will transparently configure the Docker daemon as well as OpenShift to use the specified proxies.

  • minishift start honors the environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY. The environment variables can be specified in lower case or upper case. The lower case variables take higher precedence over upper case variables. If these variables are set, they are implicitly used during minishift start unless explicitly overridden by the corresponding command line flags.

  • Minishift does not escape the special characters in the environment variables for proxy so user need to escape special characters manually to get it working.

Networking

The Minishift VM is exposed to the host system with a host-only IP address that can be obtained with the minishift ip command.

Connecting to the Minishift VM with SSH

You can use the minishift ssh command to interact with the Minishift VM.

You can run minishift ssh without a sub-command to open an interactive shell and run commands on the Minishift VM in the same way that you run commands interactively on any remote machine using SSH.

You can also run minishift ssh with a sub-command to send the sub-command directly to the Minishift VM and return the result to your local shell. For example:

  1. $ minishift ssh -- docker ps
  2. CONTAINER IMAGE COMMAND CREATED STATUS NAMES
  3. 71fe8ff16548 openshift/origin:v1.5.1 "/usr/bin/openshift s" 4 minutes ago Up 4 minutes origin