How to set up a Docker Host

the simple way

Let
client = Docker client
server = Docker Host

So that
client is your computer (Mac, Linux, *BSD or other) where you have docker application installed, and you do your software development. Server is a Linux computer/server where you have dockerd and containerd and sshd installed and running.

However, if you do not have a docker installed on the client or server, please follow the next installation example. Otherwise, please skip to the configuration session.

Client install example (macOS)

Server install example (Arch Linux)

Additional docker.service configuration can be found here

Configuration

The Client computer has to connect to the Docker server via TCP. We’ll use SSH protocol to establish a connection between client and server, so that the client can manage the Docker host remotely and use its resources.

## server

Docker needs to listen to the network, so we have to change docker service configuration.

Changing the ExecStart configuration

Then start docker service.

Client

The client has to be able to connect to the server via ssh. To better manage ssh sessions, (optionally) configure ssh key login.

ssh

To configure ssh key on the client-side:

then send the ssh public key to the server, by copying the public key from client to server.

without mention the -i parameter in the ssh-copy-id command, it will (by default) assume -i ~/.ssh/id_rsa.pub

docker

Configure docker to use remote HOST resources, by setting DOCKER_HOST environment variable:

To make it persistent:

Run docker on client to check

Note that every deployment to this docker instance will be hosted and its ports published on the remote host.
So, when you run

take in account that, port 8080 is published on 192.168.1.10 (in this example)

That’s it!

System Architect