Docker & Container Runtimes, Mint

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

After learning how to install Docker on Linux Mint 18 and 18.1 using this article and using this other one for learning how to install Docker Machine on the same distribution, the next logical step is to use that Docker Machine to provision Dockerized hosts, or machines, on supported Cloud platforms.

And that is the subject of this article – How to use Docker Machine to provision Dockerized hosts on a supported Cloud hosting provider. For this article, we’ll be provisioning the servers on the DigitalOcean platform, which offers cheap servers with SSD storage.

For this to work, you’ll need to have a DigitalOcean account. To sign up you may use this link. It’s an affiliate link, so using it to sign up benefits me and this site. You’ll also need to generate a DigitalOcean API token, which will be used for authentication when provisioning a machine. Use this DigitalOcean article to learn how to generate one.

Create a Bash Variable for Your DigitalOcean API Token

The DigitalOcean 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 from Linux Mint 18/18.1

At this point, you may start provisioning machines using the docker-machine command. And we’ll be doing that on the DigitalOcean platform. If you have VirtualBox installed, you can also provision machines locally. The 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 DigitalOcean with the latest Docker Engine installed. And though the last line of the output will tell you how to connect your Docker client to the remote machine, the best method is to employ the docker-machine use command. By default, that machine will be running the latest Ubuntu LTS version, which is Ubuntu 16.04 at the time of this writing. It will also be the smallest DigitalOcean Droplet, with 512 MB of RAM.

Related Post:  So what happens when Linux Mint 18.2 Cinnamon crashes?

You can instruct Docker Machine to use an operating system other than Ubuntu 16.04, and even specify the size of the Droplet, that is, how much RAM it should be allocated.

Provision Multiple Dockerized Host from Linux Mint 18/18.1

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 from Linux Mint 18/18.1

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/18.1. 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.

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.

Related Post:  What is Kubernetes? An intro for beginners

Running Containers on Remote Machines form Linux Mint 18/18.1

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 DigitalOcean platform from your Linux Mint 18 or 18.1 desktop. DigitalOcean is just one of many Cloud platforms supported by Docker Machine out of the box. The complete list of core drivers are available here. In a future article, we’ll show how to perform the same operations on the Vultr Cloud platform.

Panel menu Linux Mint 17.3 Cinnamon

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

Google has got competition, because Presearch is building a blockchain-based search engine controlled by the community. At $0.15 a token, you can participation in Lot 3 of the token sale by clicking here

Open Money is building a solution that will run mainstream software on blockchain tech. Click here to get free tokens that will be the digital currency of the platform

COMSA allows centralized businesses to adopt blockchain technology. The token sale starts soon! Sign up for free by clicking here

Register now for Blockchain & Cryptocurrency Con 2018, international conference on blockchain technnology in Dallas, TX (USA), Feb. 23-24, 2018. Students can register at a 50% discount.

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).


Leave a Comment

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

*