Skip to content

Latest commit

 

History

History
83 lines (49 loc) · 2.34 KB

docker-machine-base.rst

File metadata and controls

83 lines (49 loc) · 2.34 KB

Get Started With Docker & Docker Machine

How to install Docker and how to use Docker Machine to manage Docker instances

The easy way is to not install Docker, just let Docker Machine do the job, in order to do that install Docker Machine.

Important

First of all let's remove stupid issue with Windows bash console and trailing slash that I do not want to cover, in order to resolve this issue we will use Linux machine only.

From an Linux console install Docker Machine with the following commands:

$ curl -L https://github.com/docker/machine/releases/download/v0.13.0/docker-machine-`uname \
  -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine

Take some scripts from our Github account, that will be useful later:

$ git clone https://github.com/sangahco/docker-machine-cli.git
$ cd docker-machine-cli
$ chmod a+x *.sh

In order to manage Amazon EC2 Instances set two environment variables, these two keys are generated by Amazon service in order to send request to their API:

export AWS_ACCESS_KEY=myaccesskey
export AWS_SECRET=mysecretkey

for more info read this: https://aws.amazon.com/developers/access-keys/

You can put the previous code inside the .bashrc file inside the user home folder and than update the user environment with the following command:

$ source ~/.bashrc

Create Amazon EC2 Machine (Docker Host)

$ /bin/sh create-aws-machine.sh <MACHINE NAME>

List Available Machines

$ docker-machine ls

Connect to EC2 Machine (Docker Host)

Connect to a machine with the following command, replacing aws1 with the machine name from the previous command:

$ docker-machine env aws1
$ eval $(docker-machine env aws1)

Check Active Machine

$ docker-machine active

Stop Machine

$ docker-machine stop aws1

Remove (Terminate) Machine

Important

This command will terminate the instance and will be removed from the Amazon EC2

$ docker-machine rm aws1