vmwareworkstation

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

README

Docker Machine VMware Workstation Driver

Windows Build Status

This is a plugin for Docker Machine allowing to create Docker hosts locally on VMware Workstation

This as placeholder and collaboration point to add a vmware workstation driver. This is reusing part of the code from the fusion driver bundled with docker machine(as both have the same executable) and adding some code from Packer vmware driver to detect the location of the files on windows.

As the title says this is still WIP and im working to add functionality listed on the TODO list, i accept suggestions.

TODO

  • drivers/vmwareworkstation/workstation.go: Rework file for vmware workstation
  • add windows support
  • add cmd/machine-driver-vmwareworkstation.go
  • Add Linux/OSX support
  • Add dhcplease file discovery on windows
  • Add tests cases
  • Create makefile
  • Add docs/drivers/vm-workstation.md

Requirements

Installation

The latest version of docker-machine-driver-vmwareworkstation binary is available on the "Releases" page.

Put the executable in the directory containing docker-machine.exe, or else add it to your $PATH.

Installing with Docker Toolbox

InstallDocker Toolbox without VirtualBox

DockerToolbox-.exe /COMPONENTS="Docker,DockerMachine"

Replace contents of "C:\Program Files\Docker Toolbox\start.sh" with this

#!/bin/bash

export PATH="$PATH:/mnt/c/Program Files (x86)/VMware/VMware Workstation"

trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong in step ´$STEP´... Press any key to continue..."' EXIT

VM=${DOCKER_MACHINE_NAME-default}
DOCKER_MACHINE=./docker-machine.exe

BLUE='\033[1;34m'
GREEN='\033[0;32m'
NC='\033[0m'


if [ ! -f "${DOCKER_MACHINE}" ]; then
  echo "Docker Machine is not installed. Please re-run the Toolbox Installer and try again."
  exit 1
fi

vmrun.exe list | grep \""${VM}"\" &> /dev/null
VM_EXISTS_CODE=$?

set -e

STEP="Checking if machine $VM exists"
if [ $VM_EXISTS_CODE -eq 1 ]; then
  "${DOCKER_MACHINE}" rm -f "${VM}" &> /dev/null || :
  rm -rf ~/.docker/machine/machines/"${VM}"
  #set proxy variables if they exists
  if [ -n ${HTTP_PROXY+x} ]; then
    PROXY_ENV="$PROXY_ENV --engine-env HTTP_PROXY=$HTTP_PROXY"
  fi
  if [ -n ${HTTPS_PROXY+x} ]; then
    PROXY_ENV="$PROXY_ENV --engine-env HTTPS_PROXY=$HTTPS_PROXY"
  fi
  if [ -n ${NO_PROXY+x} ]; then
    PROXY_ENV="$PROXY_ENV --engine-env NO_PROXY=$NO_PROXY"
  fi  
  "${DOCKER_MACHINE}" create -d vmwareworkstation $PROXY_ENV "${VM}"
fi

STEP="Checking status on $VM"
VM_STATUS="$(${DOCKER_MACHINE} status ${VM} 2>&1)"
if [ "${VM_STATUS}" != "Running" ]; then
  "${DOCKER_MACHINE}" start "${VM}"
  yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}"
fi

STEP="Setting env"
eval "$(${DOCKER_MACHINE} env --shell=bash ${VM})"

STEP="Finalize"
clear
cat << EOF


                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

EOF
echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}${VM}${NC} machine with IP ${GREEN}$(${DOCKER_MACHINE} ip ${VM})${NC}"
echo "For help getting started, check out the docs at https://docs.docker.com"
echo
cd

docker () {
  MSYS_NO_PATHCONV=1 docker.exe "$@"
}
export -f docker

if [ $# -eq 0 ]; then
  echo "Start interactive shell"
  exec "$BASH" --login -i
else
  echo "Start shell with command"
  exec "$BASH" -c "$*"
fi

Credit to @gtirloni

Usage

Official documentation for Docker Machine is available here.

To create a VMware Workstation virtual machine for Docker purposes just run this command:

$ docker-machine create --driver=vmwareworkstation dev

Available options:

  • --vmwareworkstation-boot2docker-url: The URL of the boot2docker image.
  • --vmwareworkstation-disk-size: Size of disk for the host VM (in MB).
  • --vmwareworkstation-memory-size: Size of memory for the host VM (in MB).
  • --vmwareworkstation-cpu-count: Number of CPUs to use to create the VM (-1 to use the number of CPUs available).
  • --vmwareworkstation-ssh-user: SSH user
  • --vmwareworkstation-ssh-password: SSH password

The --vmwareworkstation-boot2docker-url flag takes a few different forms. By default, if no value is specified for this flag, Machine will check locally for a boot2docker ISO. If one is found, that will be used as the ISO for the created machine. If one is not found, the latest ISO release available on boot2docker/boot2docker will be downloaded and stored locally for future use. Note that this means you must run docker-machine upgrade deliberately on a machine if you wish to update the "cached" boot2docker ISO.

This is the default behavior (when --vmwareworkstation-boot2docker-url=""), but the option also supports specifying ISOs by the http:// and file:// protocols.

Environment variables and default values:

CLI option Environment variable Default
--vmwareworkstation-boot2docker-url WORKSTATION_BOOT2DOCKER_URL Latest boot2docker url
--vmwareworkstation-cpu-count WORKSTATION_CPU_COUNT 1
--vmwareworkstation-disk-size WORKSTATION_DISK_SIZE 20000
--vmwareworkstation-memory-size WORKSTATION_MEMORY_SIZE 1024
--vmwareworkstation-ssh-user WORKSTATION_SSH_USER docker
--vmwareworkstation-ssh-password WORKSTATION_SSH_PASSWORD tcuser

Development

Build from Source

If you wish to work on VMWare Workstation Driver for Docker machine, you'll first need

  • Go installed (version 1.6+ is required).
    • Make sure Go is properly installed, including setting up a GOPATH.
  • MSYS
    • Make We well need to use pacman to install make
  • Currently build only works on Windows (WIP to get ti work on other platforms)

Run these commands to build the plugin binary:

$ go get -d github.com/pecigonzalo/docker-machine-vmwareworkstation
$ cd $GOPATH/github.com/pecigonzalo/docker-machine-vmwareworkstation
$ make

After the build is complete, bin/docker-machine-driver-vmwareworkstation binary will be created. If you want, copy it to the ${GOPATH}/bin/.

Authors

Credits

Documentation

Index

Constants

View Source
const (
	B2DUser = "docker"
	B2DPass = "tcuser"
)

Variables

View Source
var (
	ErrMachineExist    = errors.New("machine already exists")
	ErrMachineNotExist = errors.New("machine does not exist")
	ErrVMRUNNotFound   = errors.New("VMRUN not found")
)

Functions

func NewDriver

func NewDriver(hostName, storePath string) drivers.Driver

Types

type Driver

type Driver struct {
	*drivers.BaseDriver
	Memory         int
	DiskSize       int
	CPU            int
	ISO            string
	Boot2DockerURL string
	CPUS           int

	SSHPassword    string
	ConfigDriveISO string
	ConfigDriveURL string
}

Driver for VMware Workstation

func (*Driver) Create

func (d *Driver) Create() error

func (*Driver) DriverName

func (d *Driver) DriverName() string

DriverName returns the name of the driver

func (*Driver) GetCreateFlags

func (d *Driver) GetCreateFlags() []mcnflag.Flag

GetCreateFlags registers the flags this driver adds to "docker hosts create"

func (*Driver) GetIP

func (d *Driver) GetIP() (string, error)

func (*Driver) GetSSHHostname

func (d *Driver) GetSSHHostname() (string, error)

func (*Driver) GetSSHUsername

func (d *Driver) GetSSHUsername() string

func (*Driver) GetState

func (d *Driver) GetState() (state.State, error)

GetState returns the current state of the machine.

func (*Driver) GetURL

func (d *Driver) GetURL() (string, error)

func (*Driver) Kill

func (d *Driver) Kill() error

func (*Driver) PreCreateCheck

func (d *Driver) PreCreateCheck() error

PreCreateCheck checks that the machine creation process can be started safely.

func (*Driver) Remove

func (d *Driver) Remove() error

func (*Driver) Restart

func (d *Driver) Restart() error

func (*Driver) SetConfigFromFlags

func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error

func (*Driver) Start

func (d *Driver) Start() error

func (*Driver) Stop

func (d *Driver) Stop() error

func (*Driver) Upgrade

func (d *Driver) Upgrade() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL