Setting up your own Docker host engine


When I first got serious about learning Docker it was for rather selfish reasons and that was to save money on my hosting by using Docker to containerize the websites I had at the time.  I’ve not finished yet but I’m getting there.  I wanted a single “rented” host running virtualization of some sort.

Digital Ocean has turned out to be a quality and economic approach to getting this done.  Digital Ocean does supply an already pre-packaged Docker application service that you can be up and running on in a very short amount of time.  I am a thick headed DIY sort of guy and decided “nope! let me just spin up a droplet and set Docker up myself.”

Following the instructions that I published in a previous article I set up the Docker engine and what follows are the instructions for connecting the docker-machine CLI tool to this new instance.  It’s not that hard to do and is fairly rewarding.

Get ‘er Done!

OS Considerations

In case you might be wondering I set my Docker hosting machine up with Ubuntu 18.04LTS.  This is a distro that I’ve learned to love given I have machines provisioned with it that except for the fact I periodically reboot all my machines about once every quarter probably could have run for years with Ubuntu.  I have one last aging Debian server that sometime this calendar year I plan to swap out with Ubuntu.

Authentication Bits

I am assuming at this point you have a machine set up with docker-ce installed and running at this point. If not go back and do that.

You want to create an account on your machine and I used the same account name as exists on my laptop.

On your hosting machine as root

The “moduser” invocation adds the user to the docker user group allowing access to the docker CLI and associated operations.

Next you’ll want to create (if you don’t already have one) a RSA ssh key

On your local host as yourself

Take the public key that is generated (~/.ssh/ and copy it to the clipboard.

On the remote host as yourself you are going to create (if it doesn’t already exist) the .ssh directory and an authorized_keys file inside the .ssh directory.

On your local host ensure you are able to ssh as yourself to the remote host without being prompted for a password.

Once that is done it is now time to initialize the docker-machine.

Setup docker-machine

What you need going into this is the following information:

  • Fully qualified domain name of the Docker host
  • IP Address of the Docker host
  • path to your ssh public key

On your local host as yourself execute the following

Where USER is the userid you are logging into the remote host with, IP is the IP Address of the remote host and FQDN is the fully qualified domain of the remote host.


You should now be able to connect to and redirect your docker CLI to the remote host.

To set up the connection do the following on your local host as yourself:

This sets environmental values in your shell that tell the docker CLI where to send the actual requests you are making to.  If you want to see what is actually set simply run

In both cases substitute FQDN with the fully qualified domain name you used earlier.


Start with something simple:


That’s it!

Copyright DevOps — In the Trenches 2019
Tech Nerd theme designed by Siteturner