Docker & Container Runtimes, Mint, Ubuntu

Provision Dockerized hosts on Vultr with Docker Machine from Linux Mint 18.1, Ubuntu 16.04

In this article, you’ll learn how to use Docker Machine to provision Dockerized hosts on the Vultr Cloud platform from your Linux Mint 18.1 or Ubuntu 16.04 desktops.

To complete the tasks in this article succesfully, you’ll need to have read:

And most importantly, you’ll need to have a Vultr account. If you don’t have one, you may sign up using this link. It’s an affiliate link, so using it to sign up benefits me and helps to keep this website going. The main benefit you’ll get from using Vultr is that their base server comes with 50% more RAM than other Cloud hosting providers’.

Generate Your Vultr Cloud API Token

After signing up for a Vultr account, assuming you did not have one already, the next task it to generate a Vultr API token, which will be used for authentication. To generate the token, log into your account and click on the Account tab on the left. Follow that by clicking on API. Then click on the Enable API button.

Generate Vultr Cloud platform API token
Figure 1: Generating your Vultr Cloud platform API token

Your Vultr API token has been generated. You may copy it to a file on your computer. Actually, it will make things easier if you copied it to a file on your computer.

Vultr Cloud platform API token
Figure 2: Vultr Cloud platform API token

Create a Bash Variable for Your Vultr API Token

The Vultr API token is a long string that can be difficult to work with on the command line. To make things easier, it’s better to assign it to a Bash variable. And the best method of doing that is to add it to the .bashrc file under your home directory. Use the following commands to accomplish that.

Provision One Dockerized Host on Vultr Cloud

At this point, you may start provisioning machines on Vultr using the docker-machine create command. The complete command you need to provision your first machine is given below.

It will take about three minutes, but after that, you’ll have a server on Vultr with the Docker Engine installed. However, that server will not be running some standard Linux distribution like Ubuntu, Debian, or Fedora, but instead, will be running RancherOS, an operating system designed just for running containers. Called a container-native operating system, it’s one of many of its kind in active development. See this article for a partial list of container-native operating systems in active development.

In the next section, you’ll learn how to provision a machine on Vultr using an operating system other than RancherOS.

Provision a Dockerized Host on Vultr using an OS other than RancherOS

By adding the –vultr-os-id option to the docker-machine create command, you can create a machine running an operating system other than RancherOS. The value to that option is a 3-digit number that corresponds to the operating system. The list of operating systems available on Vultr are on a link that displays in a difficult-to-read JSON format. How to display the list in a more readable JSON format is given in Display a list of available operating systems on Vultr in pretty JSON.

Related Post:  How to provision Dockerized hosts with Docker Machine from Linux Mint 18, 18.1

Using the following command, you instruct Docker Machine to create a Dockerized host with Debian 8 Jessie, whose id is 193.

Provision Multiple Dockerized Host on Vultr

Provisioning one Dockerized host is nice, but the command can be extended with a little Bash magic to provision as many as you can afford to pay for. For example, the commands you may use to provision two or more machines are given next.

With those commands, you’ve now seen how you can provision hundreds, even thousands of Dockerized hosts with a single command.

Managing Dockerized Hosts On vultr from Linux Mint 18.1, Ubuntu 16.04

With Docker Machine, managing Dockerized hosts is not complicated. In this section, you’ll become familiar with basic commands you’ll need to work with it on Linux Mint 18.1 or Ubuntu 16.04. The simplest command you’ll be using regularly is docker-machine ls, which is used to list provisioned machines. The output is given in the following code block.

So how do you activate a machine? By using the following command. Note that when a machine is activated, your Docker client is connected to it, so that all Docker commands (not Docker Machine commands) you type are executed on it.

If you installed Docker Machine using this article, activating a machine will include its name in your command prompt. That makes it easy to keep track of which machine you’re working on when you have multiple machines.

Related Post:  Upgrade Ubuntu 16.10 to Ubuntu 17.04. Your swap partition will be retained

A Dockerized host is just like any other server, so you can log into it using SSH and perform all the administrative tasks you need to. You can also log into it using the docker-machine ssh command. And with a variation of the same command, it’s possible to execute any command on the machine and perform the same administrative tasks without actually logging into it. Below are a few example commands you can execute on a remote machine using the docker-machine ssh command.

Running Containers on Dockerized Hosts on Vultr

The whole point of provisioning a server with Docker Engine installed on it is to be able to run containers on it. As you saw in the previous section, with Docker Machine, you can do that without actually logging into the machine in the traditional way. The following commands show how to run containers on a remote machine using the docker-machine ssh command.

Cleaning Up

After provisioning and test-driving one or more Dockerized hosts, there will come a time when you’ll need to stop and/or destroy them. This last set of commands show how to go about it.

Resources

The foregoing has shown how to provision Dockerized hosts, or machines, on the Vultr platform from your Linux Mint 18.1 or Ubuntu 16.04 desktop. The Vultr Docker Machine driver is just one of many available for Docker Machine. You may view the complete list here. For the list of core drivers supported by Docker Machine, click here. And if you have not yet signed up for a Vultr account, you may do so now using this link.

Subscribe to LinuxBSDos.com

Subscribe to receive the latest articles in your Inbox

Trust me, you'll not be spammed...

Please share:

We Recommend These Vendors and Free Offers

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).

Deploy an SSD Cloud server in 55 seconds on DigitalOcean. Built for developers and starting at $5:00/month (20 GB SSD, 512 MB of RAM).

Want to become an expert ethical hacker and penetration tester? Request your free video training course of Online Penetration Testing and Ethical Hacking

Whether you're new to Linux or are a Linux guru, you can learn a lot more about the Linux kernel by requesting your free ebook of Linux Kernel In A Nutshell.


Leave a Comment

Your email address will not be published. Required fields are marked *

*