Using Docker Machine

Let's take a look at how we can use Docker Machine to deploy Docker hosts on your local infrastructure, on your own machine, as well as on various cloud providers.

Local VM

Docker Machine uses the --driver switch to specify the location you want to set up and install the Docker host. So, we can set up a Docker host in VirtualBox:

$ docker-machine create --driver virtualbox <name>

Or, we can set it up on VMware Fusion:

$ docker-machine create --driver vmwarefusion <name>

The previous command is structured as the docker-machine command, followed by what we want to do: create. We will use the --driver switch next. Then, we need to specify where we are going to place the Docker host. In our case, we specified virtualbox and vmwarefusion. Lastly, we need to give the Docker host a name. This name is to be unique; so when you issue other Docker Machine commands, they are distinguishable.

There are various other switches we can use to tell how much memory the Docker host to use and also how much disk space to use as well. You can see all the available switches by issuing our trustworthy and helpful docker-machine create --help command. Remember that everything has a --help switch that can be utilized to gain more information to get the help you need. It should be the first thing you turn to when you are looking for assistance.

Cloud environment

Now, let's take a look at how we deploy to a cloud environment of our choosing. When you start deploying to cloud environments, it can get tricky, as it requires some form of authentication to ensure you are who you say you are. For example, DigitalOcean requires an access token to launch a Docker host in its system. We will be taking a look at how we can deploy a Docker host in AWS.

For AWS, we need a couple of switches. We would need to get the information from AWS before we can deploy to this cloud provider:

  • --amazonec2-access-key
  • --amazonec2-secret-key
  • --amazonec2--vpc-id
  • --amazonec2-zone
  • --amazonec2-region

We can create these drivers by executing the following command:

$ docker-machine create 
   --driver amazonec2 
   --amazonec2-access-key <aws_access_key> 
   --amazonec2-secret-key <aws_secret_key> 
   --amazonec2-vpc-id <vpc_id> 
   --amazonec2-subnet-id <subnet_id> 
   --amazonec2-zone <zone> 
     <name>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset