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:  Setting up a RabbitMQ container using Rancher

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:  Use NVIDIA-Docker to deploy machine learning models

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

LinuxBSDos needs your donation to continue!

I hope this article has saved you valuable time and effort to fix a problem that would have taken more time than is necessary. That makes me happy, and why I love doing this. But because more people than ever are reading articles like this with an adblocker, ad revenues have fallen to a level that's not enough to cover my operating costs. That's why I want to ask you a favor: To make a one-time or recurring donation to support this site and keep it going. It's a small favor, but every one counts. And you can make your donation using Patreon or directly via Paypal. Thank you for whatever donation you're able to make.

Donate via Patreon. Donate via Paypal.

Aside from donation, you may also signup to receive an email once I publish new content. Your email will not be shared or traded to anyone. And you can unsubscribe at any time.

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 *

*