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

$ adduser peter
$ moduser --append -G docker

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

$ ssh-keygen -t rsa

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.

$ mkdir .ssh
$ cd .ssh
$ vi authorized_keys 
    # paste in the copied key
$ chmod 600 authorized_keys
$ chmod 700 . 
$ cd 

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

$ docker-machine create \
  --driver generic \
  --generic-ip-address=IP  \
  --generic-ssh-key ~/.ssh/id_rsa \
  --generic-user USER \

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:

$ eval $(docker-machine env FQDN)

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

$ docker-machine env FQDN

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


Start with something simple:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:


That’s it!

About: peter

Leave a Reply

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