Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Docker Machine

satrapu edited this page Oct 14, 2017 · 4 revisions

This page details how to run Rancher server and 2 agents on VMs created via Docker Machine.

This is the approach to be used during this workshop!

RancherOS

This OS was built specifically for hosting Docker containers and it's officially supported by Rancher server.

You can control a RancherOS instance via ros command:

$ sudo ros
# NAME:
#   ros - Control and configure RancherOS
#built: '2017-08-08T00:05:15Z'
#
#USAGE:
#   ros [global options] command [command options] [arguments...]
#
#VERSION:
#   v1.0.4
#
#AUTHOR(S):
#   Rancher Labs, Inc.
#
#COMMANDS:
#     config, c   configure settings
#     console     manage which console container is used
#     engine      manage which Docker engine is used
#     service, s
#     os          operating system upgrade/downgrade
#     tls         setup tls configuration
#     install     install RancherOS to disk
#     selinux
#    help, h     Shows a list of commands or help for one command
#
#GLOBAL OPTIONS:
#   --help, -h     show help
#   --version, -v  print the version

Create VMs Using Docker Machine

More information can be found here and here.
On Windows, please run docker-machine as admin!

Create Rancher server Docker machine

docker-machine create -d virtualbox --virtualbox-boot2docker-url https://releases.rancher.com/os/v1.0.4/rancheros.iso --virtualbox-cpu-count 2 --virtualbox-memory 2048 --virtualbox-disk-size 10000 rs

Create Rancher agent #1 Docker machine

docker-machine create -d virtualbox --virtualbox-boot2docker-url https://releases.rancher.com/os/v1.0.4/rancheros.iso --virtualbox-cpu-count 2 --virtualbox-memory 2048 --virtualbox-disk-size 20000 ra1

Create Rancher agent #2 Docker machine

docker-machine create -d virtualbox --virtualbox-boot2docker-url https://releases.rancher.com/os/v1.0.4/rancheros.iso --virtualbox-cpu-count 2 --virtualbox-memory 2048 --virtualbox-disk-size 20000 ra2

Get Docker machine IP address

In order to obtain the IP address of a VM created via docker-machine, run the following command:

# Solution #1
docker-machine ip <DOCKER_MACHINE_NAME>
 
# Solution #2
docker-machine inspect <DOCKER_MACHINE_NAME> --format={{.Driver.IPAddress}}

Connect to Docker machine via SSH

docker-machine ssh rs
docker-machine ssh ra1
docker-machine ssh ra2

Change Docker machine system parameters

In case your Rancher server is keep showing an error page, check the rs machine logs. You might see:

...
time="2017-08-20T16:29:03Z" level=info msg="Starting Catalog Service (port 8088, refresh interval 300 seconds)"
fatal error: runtime: out of memory
...

If this is the case, you may want to allocated more RAM to this machine.

# stop VM
docker-machine stop <DOCKER_MACHINE_NAME>
 
# set number of CPU cores
VBoxManage modifyvm <DOCKER_MACHINE_NAME> --cpus 2
 
# set amount of RAM in MB
VBoxManage modifyvm <DOCKER_MACHINE_NAME> --memory 4096
 
# start VM
docker-machine start <DOCKER_MACHINE_NAME>
Clone this wiki locally