Docker Machine

From Training Material
Revision as of 22:25, 18 March 2019 by Kbaran (talk | contribs) (→‎Installation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Author


Installation

$ sudo -i
$ curl -L https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-`uname -s`-`uname -m` > /usr/local/bin/docker-machine
$ chmod +x /usr/local/bin/docker-machine
$ curl -L https://raw.githubusercontent.com/docker/machine/master/contrib/completion/bash/docker-machine.bash > /etc/bash_completion.d/docker-machine.bash
$ exit
$ docker-machine --version
  • more info about installation: docs.docker.com/machine/install-machine/ and supported drivers: docs.docker.com/machine/drivers/


Docker-Machine Drivers

Amazon Web Services

docker-machine create \
  --driver amazonec2 \
  --amazonec2-vpc-id vpc-6f559a0a \
  --amazonec2-access-key AKI...EQA \
  --amazonec2-secret-key A6Z...AKM \
  --amazonec2-region eu-west-1 \
  --amazonec2-zone b \
  --amazonec2-instance-type t2.small \
  --amazonec2-ami ami-00035f41c82244dab \
  --amazonec2-root-size 8 \
  --amazonec2-security-group myGroup \
  aws-machine-1


Microsoft Azure

docker-machine create \
  --driver azure \
  --azure-subscription-id 5a4...30d2 \
  --azure-location 'West Europe' \
  --azure-resource-group training \
  --azure-size Standard_B2s \
  --azure-vnet training \
  --azure-open-port 80 \
  azure-machine-1


Oracle VirtualBox

docker-machine create \
  --driver=virtualbox \
  --virtualbox-memory=1024 \
  --virtualbox-disk-size=4096 \
  boot2docker-machine-1


Generic driver

Make sure you can connect, from server-s0 to server-s1 and server-s2 using public key authentication

$ ssh-keygen
$ ssh-copy-id ubuntu@server-s1
$ ssh ubuntu@server-s1
$ exit
$ ssh-copy-id ubuntu@server-s2
$ ssh ubuntu@server-s2
$ exit


Make sure you are using passwordless sudo and create a new docker hosts.

$ docker-machine create --driver generic --generic-ip-address server-s1 --generic-ssh-user ubuntu server-s1
$ docker-machine create --driver generic --generic-ip-address server-s2 --generic-ssh-user ubuntu server-s2
$ docker-machine ls


Run web server on server-s1

$ eval $(docker-machine env server-s1)
$ docker-machine active
$ docker run -d -p 80:80 httpd:alpine
$ eval $(docker-machine env -u)
$ docker-machine active